guard / guard-spork

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

Problem with signal handlers when using guard-spork with rb-fsevent #20

Closed simonbennett closed 13 years ago

simonbennett commented 13 years ago

Attempting to stop guard with Ctrl-C gives:

/gems/rb-fsevent-0.4.0/lib/rb-fsevent/fsevent.rb:44:in `kill': No such process (Errno::ESRCH)

Ctrl-\ gives the same error. Attempting to run guard again gives:

Address already in use - bind(2) (Errno::EADDRINUSE)

guard-spork without rb-fsevent == works as expected guard-rspec with rb-fsevent == works as expected

ruby 1.8.7 spork 0.8.4 (also tried 0.8.5 and 0.9.0.rc.x) guard 0.3.4 guard-spork 0.1.10 guard-rspec 0.3.1 rb-fsevent 0.4.0

Any suggestions?

Thanks

thibaudgg commented 13 years ago

Same issue with Guard 0.4.0.rc ?

simonbennett commented 13 years ago

Yes, just tried it with Guard 0.4.0.rc and get the same issue.

thibaudgg commented 13 years ago

Please can you give your Guardfile & Gemfile. A failed example app would also be awesome.

simonbennett commented 13 years ago

Example app:

git@github.com:simonbennett/guard_spork_example.git

Steps to reproduce error in README.

Thanks

Gemfile

source 'http://rubygems.org'

gem 'rails', '3.0.7'

gem 'sqlite3'

group :test do
  gem 'rb-fsevent'
  gem 'spork', '0.8.4'
  gem 'guard'
  gem 'guard-rspec'
  gem 'guard-spork'
end

group :development, :test do
  gem 'rspec-rails'
  gem 'growl'
end

Guardfile

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch(%r{^config/environments/.+\.rb$})
  watch(%r{^config/initializers/.+\.rb$})
  watch('spec/spec_helper.rb')
end

guard 'rspec', :cli => '--drb', :version => 2 do
  watch(%r{^spec/.+_spec\.rb})
  watch(%r{^lib/(.+)\.rb})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb') { "spec" }

  # Rails example
  watch('spec/spec_helper.rb')                       { "spec" }
  watch('config/routes.rb')                          { "spec/routing" }
  watch('app/controllers/application_controller.rb') { "spec/controllers" }
  watch(%r{^spec/.+_spec\.rb})
  watch(%r{^app/(.+)\.rb})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^lib/(.+)\.rb})                           { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
end
thibaudgg commented 13 years ago

Ok, you need to use the last version of Spork. Please try with gem 'spork', '0.9.0.rc8' instead of gem 'spork', '0.8.4'. It should work fine after that.

simonbennett commented 13 years ago

Hmm, tried it again with spork 0.9.0.rc8 and guard 0.4.0.rc - get the same errors

thibaudgg commented 13 years ago

Are you still using Ruby 1.8.7? It works well for me with ruby 1.9.2. Please can you try to update our Ruby and also Rubygems

simonbennett commented 13 years ago

Works fine on 1.9.2 - thanks for your help & for a great gem :)

thibaudgg commented 13 years ago

Great, thanks!

derekprior commented 13 years ago

Just wanted to chime in and say I've seen similar behavior when attempting to re-run my specs with ctrl-. The really frustrating part is that I can't seem to figure out how to fix this without restarting OS X. I've tried killing all running ruby processes, but then I restart guard and my rspec runs over spork just time out.

I am using REE 1.8.7. I've repro'd this twice, but this work machine takes AGES to reboot (thanks to AD integration and full disk encryption) so I haven't stripped things down to a base example yet. Do you know of a way I can get things running again WITHOUT rebooting? If I could do that, I'd try to strip things down a bit.

I might get some time to do that next week

suzi2000 commented 13 years ago

I have installed guard and guard-spork for the first time today and I've had the same error on Ubuntu 11.04, rails 3.1 rc5, spork 0.9.0.rc9 it happens as soon as the spec_helper or guardfile is changed, and spork tries to reload its environment as defined in the Guardfile via guard init spork. The test suite runs fine anyhow, but it throws these errors in the terminal window:

Reloading Spork for RSpec 
Spork server for RSpec successfully reloaded
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Address already in use - bind(2) (Errno::EADDRINUSE)
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:861:in `initialize'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:861:in `open'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:861:in `open_server'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:759:in `block in open_server'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:757:in `each'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:757:in `open_server'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1342:in `initialize'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1630:in `new'
/home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1630:in `start_service'
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0.rc9/lib/spork/server.rb:29:in `listen'
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0.rc9/lib/spork/server.rb:20:in `run'
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0.rc9/lib/spork/runner.rb:75:in `run'
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0.rc9/lib/spork/runner.rb:10:in `run'
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0.rc9/bin/spork:10:in `<top (required)>'
/home/user/.rvm/gems/ruby-1.9.2-p290/bin/spork:19:in `load'
/home/user/.rvm/gems/ruby-1.9.2-p290/bin/spork:19:in `<main>'
thibaudgg commented 13 years ago

Please can you try it with the last version of rb-fsevent (0.4.2) and the Guard master branch.

suzi2000 commented 13 years ago

Hi thibaud,

Actually i am not using any rb-fsevent gem, at leat it does not appear in my bundle list or gem list. Since i am on linux, i have rb-inotify and libnotify in my gem file. Does it make sense to add this ?

derekprior commented 13 years ago

I upgraded to the latest rb-fsevent and that kind-of solved the issue. Now the problem is that guard does not quit when hitting control c until I save a file that rb-fsevent is monitoring. Not sure if this is a problem with guard or rb-fsevent, but it doesn't seem to be an issue with spork - that's for sure.

Using the master guard branch made no difference.

thibaudgg commented 13 years ago

@suzi2000 If you're on Linux, you don't need rb-fsevent (OS X only). Does Guard master fix it for you?

@derekprior Please can you add an issue on Guard about this not quitting problem with ctrl-c. Thanks

suzi2000 commented 13 years ago

I couldnt install guard master, because it gave me errors during bundle install. maybe let me try again