guard / guard-spork

Guard::Spork automatically manage Spork DRb servers
https://rubygems.org/gems/guard-spork
MIT License
296 stars 58 forks source link

all_on_start required for guard-rspec, guard-cucumber #77

Closed aiwilliams closed 12 years ago

aiwilliams commented 12 years ago

I'm experiencing an issue where I have to provide the :all_on_start => false option to guard-rspec and guard-cucumber, or those guards will attempt to run before the drb services are running. Am I missing something? Here are my respective configurations:

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
end
guard 'rspec', :all_on_start => false, :cli => '--drb', :version => 2 do
end
guard 'cucumber', :all_on_start => false, :cli => '--drb' do
end
thibaudgg commented 12 years ago

Can you give the output when you launch guard, that seems quite unnormal!

aiwilliams commented 12 years ago

@thibaudgg I removed the all_on_start options and it seems to be working fine right now! Sorry for the bother. I'll get way more detail if it comes up again. Thank you for the great tools.

aiwilliams commented 12 years ago

Hmmm, the failure is back again:

Guard is now watching at '/Users/aiwilliams/github/organization/project'
Starting Spork for RSpec, Cucumber
Spork server for RSpec, Cucumber successfully started
Guard::RSpec is running, with RSpec 2!
Running all specs
Using Cucumber
Using RSpec
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!

This happened after I rebooted my computer thanks to Lion 10.7.4. It seems that a watch in guard-rspec block is being triggered. Is there a way I can see whether a watch is being triggered?

aiwilliams commented 12 years ago

This might be helpful:

^C

ERROR: Guard::RSpec failed to achieve its <start>, exception was:
Interrupt: 
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:566:in `read'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:566:in `load'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:632:in `recv_reply'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:918:in `recv_reply'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1197:in `send_message'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1088:in `block (2 levels) in method_missing'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1172:in `open'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-rspec-0.7.0/lib/guard/rspec/runner.rb:117:in `run_via_drb'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-rspec-0.7.0/lib/guard/rspec/runner.rb:29:in `run'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-rspec-0.7.0/lib/guard/rspec.rb:32:in `run_all'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-rspec-0.7.0/lib/guard/rspec.rb:28:in `start'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:395:in `block in run_supervised_task'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:393:in `catch'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:393:in `run_supervised_task'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:221:in `block in start'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:327:in `block (3 levels) in run_on_guards'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:326:in `each'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:326:in `block (2 levels) in run_on_guards'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:325:in `catch'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:325:in `block in run_on_guards'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:324:in `each'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:324:in `run_on_guards'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard.rb:220:in `start'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/lib/guard/cli.rb:81:in `start'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
/Users/aiwilliams/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/guard-1.0.2/bin/guard:6:in `<top (required)>'
./bin/guard:16:in `load'
./bin/guard:16:in `<main>'

Guard::RSpec has just been fired
Running all features
Using the default profile...
WARNING: No DRb server is running. Running features locally:
^C
Exiting... Interrupt again to exit immediately.
^C
thibaudgg commented 12 years ago

Are you sure that Spork is launching fine? You can launch Guard with the --verbose option to have debug output.

aiwilliams commented 12 years ago

Thank you for your help! Yes, Spork runs well when I do spork rspec or spork cucumber, and guard-spork runs fine when I config guard-rspec and guard-cucumber with :all_on_start => false.

Here is the output with --verbose when I have not :all_on_start => false:

guard --verbose
Guard is now watching at '/Users/aiwilliams/github/organization/project'
DEBUG (14:32:44): Hook :start_begin executed for Guard::Spork
DEBUG (14:32:44): Command execution: ps aux | awk '/spork/&&!/awk/{print $2;}'
DEBUG (14:32:44): Killing Spork servers with PID: 
Starting Spork for RSpec, Cucumber
Spork server for RSpec, Cucumber successfully started
DEBUG (14:32:45): Hook :start_end executed for Guard::Spork
DEBUG (14:32:45): Hook :start_begin executed for Guard::RSpec
Guard::RSpec is running, with RSpec 2!
Running all specs
DEBUG (14:32:45): Command execution: bundle exec rspec --help
Using RSpec
Using Cucumber
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!

And here is the output with --verbose when I have :all_on_start => false:

guard --verbose
Guard is now watching at '/Users/aiwilliams/github/organization/project'
DEBUG (14:42:02): Hook :start_begin executed for Guard::Spork
DEBUG (14:42:02): Command execution: ps aux | awk '/spork/&&!/awk/{print $2;}'
DEBUG (14:42:02): Killing Spork servers with PID: 
Starting Spork for RSpec, Cucumber
Spork server for RSpec, Cucumber successfully started
DEBUG (14:42:03): Hook :start_end executed for Guard::Spork
DEBUG (14:42:03): Hook :start_begin executed for Guard::RSpec
Guard::RSpec is running, with RSpec 2!
DEBUG (14:42:03): Hook :start_end executed for Guard::RSpec
DEBUG (14:42:03): Hook :start_begin executed for Guard::Cucumber
DEBUG (14:42:03): Hook :start_end executed for Guard::Cucumber
Using Cucumber
Using RSpec
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!
thibaudgg commented 12 years ago

Mmm I see, guard-spork should block until it's starts and it doesn't seems to be the case here. Which version of guard-spork are you using? Can you try with older version 0.6/0.7 to see if it do the same, thanks!

aiwilliams commented 12 years ago

I get the same result with 0.6.1, 0.7.0, 0.7.1, and 0.8.0. I tested these by changing the Gemfile to each version followed by bundle install, rbenv rehash, then guard --verbose. I'm going to try rebooting my computer and see if the problem goes away again, which has been my experience, but the problem always comes back again.

thibaudgg commented 12 years ago

That's weird it works great for me with just guard-spork & guard-rspec could you try to comment out guard-cucumber stuff.

aiwilliams commented 12 years ago

Okay, I tried it without guard-cucumber: I'm still seeing guard-rspec's :start_begin being invoked before Spork is ready and listening has completed. When I remove guard-rspec also, I still see this:

DEBUG (13:29:40): Hook :start_end executed for Guard::Spork
Using RSpec
Using Cucumber
Preloading Rails environment
Preloading Rails environment
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!

Is guard-spork supposed to block until we see that Spork is ready and listening?

thibaudgg commented 12 years ago

Yeah guard-rspec's start method should only occur when guard-spork's start is done and it's how it works on my config. Can you give more details about your config (OS, ruby) please? It would also be really helpful if you could post a complete failing example (gist or github project), so I could reproduce this issue on my machine. Thanks!

nick commented 12 years ago

I am seeing the same issue here. @aiwilliams did you find a workaround?

nick commented 12 years ago

My current workaround is to just run another instance of guard in a new terminal window. Not ideal, but it works...

aiwilliams commented 12 years ago

I never figured out what was causing the problem. I'm on a new MacBook, and I've had no problems so far.

aiwilliams commented 12 years ago

I /think/ I've figured out what's happening. It seems that sometimes a drb process is left running. When I run into the problem on my new computer, it is after I have used Ctrl-C to kill guard, and when I start it again later, this stuff happens. Then I go and kill all ruby processes, run guard again, and there is no problem!