I have setup Guard and Guar-Livereload on my new Rails project similarly on how I had on a previous one: Gemfile:
group :development do
gem 'spork-rails', '4.0.0'
gem 'guard-spork', '1.5.0'
gem 'childprocess'
gem "rspec-rails"
gem 'guard-livereload', require: false
gem 'spring'
gem "guard-rspec"
end
And in my Guardfile:
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{app/assets/.+\.rb})
watch(%r{app/assets/.+\.(css|js|scss|jpg|png)})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
end
Which was created after issuing the command guard init guard-livereload. When I issue guard I can see the following messages:
18:35:41 - INFO - Guard is using TerminalTitle to send notifications.
18:35:43 - INFO - Guard::RSpec is running
18:35:43 - INFO - LiveReload is waiting for a browser to connect.
18:35:43 - INFO - Guard is now watching at '/Volumes/volume/Users/myuser/Documents/RubyApps/myapp'
[1] guard(main)>
But the server doesn't start, however if I rails s the server will start and visible on the front end. This leads me to believe the issue is with Guard. Can anyone point me in the right direction?
Many thanks
EDIT Added console after running guard -d:
18:31:56 - DEBUG - Command execution: emacsclient --eval '1' 2> /dev/null || echo 'N/A'
18:31:56 - INFO - Guard is using TerminalTitle to send notifications.
18:31:57 - DEBUG - Command execution: hash stty
18:31:57 - DEBUG - Guard starts all plugins
18:31:57 - DEBUG - Hook :start_begin executed for Guard::RSpec
18:31:57 - INFO - Guard::RSpec is running
18:31:57 - DEBUG - Hook :start_end executed for Guard::RSpec
18:31:57 - DEBUG - Hook :start_begin executed for Guard::LiveReload
18:31:57 - DEBUG - Hook :start_end executed for Guard::LiveReload
18:31:57 - INFO - LiveReload is waiting for a browser to connect.
18:31:57 - INFO - Guard is now watching at '/Volumes/fenix/Users/wagner/Documents/htdocs/RubyApps/turing'
18:31:57 - DEBUG - Start interactor
18:31:57 - DEBUG - Command execution: stty -g 2>/dev/null`
look at #ec2's recent comment on this:
for livereload, run guard with the '-d' option (bundle exec guard -d) and you should see Hook :run_on_modifications_begin executed for Guard::LiveReload. Let us know if you get that message or not (next step depends on the answer). And of course, make sure livereload is actually turned on in your browser (I have to enable it every time I start the project) - ideally, just open a static html file in the browser, edit that file and check - it should work.
Related
I set up a clean install of Yosemite and can't get guard to detect whenever a file is changed.
My Environment:
guard (2.6.1)
guard-minitest (2.2.0)
rubygems-bundler (1.4.4)
Ruby 1.9.3 and 2.0.0 both have been testing
Here is the output from debugging:
tom#Toms-MBP:~/Sites/tick (master)$ LISTEN_GEM_DEBUGGING=2 bundle exec guard -d
I, [2014-10-27T15:34:53.417196 #1059] INFO -- : Celluloid loglevel set to: 0
15:34:53 - DEBUG - Command execution: emacsclient --eval '1' 2> /dev/null || echo 'N/A'
15:34:53 - INFO - Guard is using TerminalTitle to send notifications.
15:34:53 - DEBUG - Command execution: hash stty
15:34:53 - DEBUG - Guard starts all plugins
15:34:53 - DEBUG - Hook :start_begin executed for Guard::Minitest
15:34:53 - INFO - Guard::Minitest 2.3.2 is running, with Minitest::Unit 4.7.5!
15:34:53 - DEBUG - Hook :start_end executed for Guard::Minitest
15:34:53 - INFO - Guard is now watching at '/Users/tom/Dropbox/Sites/tick'
15:34:53 - DEBUG - Command execution: sysctl -n hw.ncpu
D, [2014-10-27T15:34:53.517668 #1059] DEBUG -- : Adapter: considering TCP ...
D, [2014-10-27T15:34:53.517749 #1059] DEBUG -- : Adapter: considering polling ...
D, [2014-10-27T15:34:53.517776 #1059] DEBUG -- : Adapter: considering optimized backend...
I, [2014-10-27T15:34:53.587089 #1059] INFO -- : Record.build(): 0.06837701797485352 seconds
15:34:53 - DEBUG - Command execution: stty -g 2>/dev/null
15:34:53 - DEBUG - Start interactor
[1] guard(main)>
I am not sure how to test the underlying listen gem, but seems like it has to be related. I have confirmed that guard works correctly with polling (bundle exec guard start --force-polling).
I was able to resolve my issue by moving the files out of Dropbox. Once I saw this working, I knew that Dropbox was somehow causing the issue with the file system. I resolved it by removing the folder and re-adding it through Dropbox and now everything is working as before.
I had the same problem, and only thanks to a warning issued by the LiveReload application I fixed it.
Because the problem is not restrained to Dropbox and/or ruby on rails, I wanted to share what I did:
Rename problematic folder (in my case containing the Guardfile)
Create new folder with the old folders name
Move files from old to new folder
Other solutions mentioned by LiveReload are:
rebooting the computer
checking the disk and repairing permissions via Disk Utility
adding the folder to Spotlight privacy list (the list of folders to not index), and then removing from it, effectively forcing a
reindexing
renaming the folder, and then possibly renaming it back
re-creating the folder and moving the old contents back into it
Read more: http://feedback.livereload.com/knowledgebase/articles/86239
This not only fixed my Guard problem, but also allowed Compass watch to run again.
Did you add rb-fsevent gem ?
group :development, :test do
gem 'rb-fsevent' if `uname` =~ /Darwin/
end
if you're using OS X, it will be used OS X FSEvents API.
I am installing openmeeting 3.0.1 in local machine. While installing i am facing following error. How to solve this issue?
WARN 05-30 16:29:27.879 o.a.o.d.d.b.ConfigurationDao:123 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] - Could not find key in configuration CONF_KEY: mail.smtp.timeout
DEBUG 05-30 16:29:27.879 o.a.o.q.s.TestSetupCleanupJob:34 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-5] - TestSetupClearJob.execute
DEBUG 05-30 16:29:27.880 o.a.o.m.MailHandler:258 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] - sendMails enter ...
DEBUG 05-30 16:29:28.114 o.a.o.m.MailHandler:260 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] - Number of emails in init queue 0
DEBUG 05-30 16:29:28.114 o.a.o.m.MailHandler:265 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] - ... sendMails done.
DEBUG 05-30 16:29:32.832 o.a.o.d.d.s.SessiondataDao:404 [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-7] - ****** clearSessionTable:
Though I see you already found a solution one may also wish to try the following:
1. Go to the releases page: https://github.com/Red5/red5-server/releases
2. Download tarball: https://github.com/Red5/red5-server/releases/download/v1.0.5-RELEASE/red5-server-1.0.5-RELEASE-server.tar.gz (or you can use *.zip)
3. Extract it somewhere
4. Run red5.sh (red5.bat)
Also, installing sendmail as part of your prerequisite can also help with SNMP Key errors
I'm using Spork and Guard in my RSpec test suite. I'm excluding slow tests from running with:
RSpec.configure do |config|
...
config.filter_run_excluding slow: true
...
end
Then when I need to I run the slow tests in a separate shell with: $ rspec . --tag slow
I'm wondering if there's a shortcut to run the slow tags in same shell that Guard is auto-running its tests in?
There's a console > prompt? And after looking at documentation I find that typing >. rspec . --tag slow works...but that's just a little more verbose than switching to another shell. Seems like this would be a fairly common request. Ideas?
You can define groups and have different rspec configurations in each group.
Append the code below to the contents of /Guardfile:
scope group: :fast
group :fast do
guard 'rspec', cli: '--tag ~slow' do
# code for watching
end
end
group :slow do
guard 'rspec', cli: '--tag slow' do
# code for watching
end
end
When you start Guard, it defaults to the fast specs:
$ guard
21:56:35 - INFO - Guard::RSpec is running
21:56:35 - INFO - Guard is now watching at '/Users/michi/testproject'
[1] {Fast} guard(main)>
Pressing enter will run all fast specs:
22:02:00 - INFO - Run Fast
22:02:00 - INFO - Running all specs
Run options: exclude {:slow=>true}
Now you can run just all the slow ones by pressing slow:
[2] {Fast} guard(main)> slow
22:02:50 - INFO - Run Slow
22:02:50 - INFO - Running all specs
Run options: include {:slow=>true}
You can also switch the scope to the slow specs and run them all by pressing enter:
[3] {Fast} guard(main)> scope slow
[4] {Slow} guard(main)>
22:03:30 - INFO - Run Slow
22:03:30 - INFO - Running all specs
Run options: include {:slow=>true}
Hope that helps!
This code will run all the test that are tagged "fast" inside the files we are watching.
guard 'rspec', :version => 2, :cli => "--tag ~fast" do
# code for watching
end
You need to use cli option to run only the tests you need.
I have a rails application that I just threw guard and minitest and my gaurd file is
guard 'minitest', :cli => '--drb --format doc --color' do
# with Minitest::Unit
watch(%r|^test/(.*)\/?test_(.*)\.rb|)
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r|^test/test_helper\.rb|) { "test" }
# Rails
watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
end
but when i run guard i get a command prompt
bundle exec guard
22:14:12 - INFO - Guard uses TerminalTitle to send notifications.
22:14:12 - INFO - Guard is now watching at '/Users/trace/Sites/application'
1.9.3 (main):0 > 2 + 2
=> 4
Why am i getting this prompt. Any ideas... here are some of the gems i am using
UPDATE...
when i run all minitest then the tests run...but why do i have to run that...any ideas
What your seeing is the Guard interactor, which makes use of Pry. Normally the prompt looks a bit different, so I assume you've a ~/.pryrc file with some configuration. With Guard 1.5.3, released yesterday, Guard ignores ~/.pryrc and only evaluates ~/.guardrc for the Pry configuration, so the normal Pry configuration is separated from the Guard Pry interactor.
When you're seeing this prompt, it means that Guard is waiting and has nothing to do. You can now start working and Guard automatically starts testing your app with minitest according to your file modifications and watcher configuration, or you can manually trigger an action.
You can get a list of the available actions with help guard. Some commands are generated depending on your Guard plugins and groups within your Guardfile. Here's an example of one of my projects:
$ bundle exec guard
09:58:14 - INFO - Guard uses GNTP to send notifications.
09:58:14 - INFO - Guard is now watching at '/Users/michi/Repositories/extranett'
09:58:15 - INFO - Guard::Jasmine starts Unicorn test server on port 8888 in development environment.
09:58:17 - INFO - Waiting for Jasmine test runner at http://dnndev.me:8888/jasmine
09:58:23 - INFO - Run all Jasmine suites
09:58:23 - INFO - Run Jasmine suite at http://dnndev.me:8888/jasmine
09:58:41 - INFO - Finished in 8.853 seconds
09:58:41 - INFO - 896 specs, 0 failures
09:58:41 - INFO - Done.
09:58:41 - INFO - Guard::RSpec is running
09:58:41 - INFO - LiveReload 1.6 is waiting for a browser to connect.
[1] guard(main)> help guard
Guard
all Run all plugins.
backend Run all backend
change Trigger a file change.
coffeescript Run all coffeescript
frontend Run all frontend
jasmine Run all jasmine
livereload Run all livereload
notification Toggles the notifications.
pause Toggles the file listener.
reload Reload all plugins.
rspec Run all rspec
show Show all Guard plugins.
[2] guard(main)> exit
09:59:39 - INFO - Guard::Jasmine stops server.
09:59:39 - INFO - Bye bye...
I am trying to use foreman to start my rails app. Unfortunately I have difficulties connecting my IDE for debugging.
I read here about using
Debugger.wait_connection = true
Debugger.start_remote
to start a remote debugging session, but that does not really work out.
Question:
Is there a way to debug a rails (3.2) app started by foreman? If so, what is the approach?
If you use several workers with full rails environment you could use the following initializer:
# Enabled debugger with foreman, see https://github.com/ddollar/foreman/issues/58
if Rails.env.development?
require 'debugger'
Debugger.wait_connection = true
def find_available_port
server = TCPServer.new(nil, 0)
server.addr[1]
ensure
server.close if server
end
port = find_available_port
puts "Remote debugger on port #{port}"
Debugger.start_remote(nil, port)
end
And in the foreman's logs you'll be able to find debugger's ports:
$ foreman start
12:48:42 web.1 | started with pid 29916
12:48:42 worker.1 | started with pid 29921
12:48:44 web.1 | I, [2012-10-30T12:48:44.810464 #29916] INFO -- : listening on addr=0.0.0.0:5000 fd=10
12:48:44 web.1 | I, [2012-10-30T12:48:44.810636 #29916] INFO -- : Refreshing Gem list
12:48:47 web.1 | Remote debugger on port 59269
12:48:48 worker.1 | Remote debugger on port 41301
Now run debugger using:
rdebug -c -p [PORT]
One approach is to require debugger normally in your gemfile, and add debugger normally in your code as needed. When the server hits that line, it will stop, but foreman won't be verbose about it. In your foreman console you can blindly type irb, and only then will you see a prompt appear. Bad UX, right?
Another (augmentative) approach is to tail your logs:
tail -f log/development.log
Hope this helps.