我正在构建一个 Rails 应用程序并使用 Spork/Guard/Rspec 进行测试。
我在 mac (10.6.8) 上——这是我正在使用的 gem:
gem "rspec-rails", "~> 2.12.1"
gem "guard-rspec", "~> 2.3.3"
gem "guard-spork", "~> 1.4.1"
gem "spork", "~> 0.9.2"
gem 'rb-fsevent', '~> 0.9.1', :require => false
gem "growl", "~> 1.0.3"
gem 'capybara', '1.1.2'
当我编辑路由文件时,它应该重新启动 spork 服务器,这是我的 Guardfile 中的行:
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, :foreman => true do
watch('config/routes.rb')
end
但是最近,当我添加新路线时,我刚刚开始收到以下错误:
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Address already in use - bind(2) (Errno::EADDRINUSE)
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `initialize'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `open'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:759:in `block in open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:757:in `each'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:757:in `open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1342:in `initialize'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1624:in `new'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1624:in `start_service'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125@h/gems/spork-0.9.2/lib/spork/server.rb:29:in `listen'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125@h/gems/spork-0.9.2/lib/spork/server.rb:20:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125@h/gems/spork-0.9.2/lib/spork/runner.rb:75:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125@h/gems/spork-0.9.2/lib/spork/runner.rb:10:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125@h/gems/spork-0.9.2/bin/spork:10:in `<top (required)>'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125@h/bin/spork:23:in `load'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125@h/bin/spork:23:in `<main>'
通常当 spork 启动时,我会得到以下信息:
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Spork is ready and listening on 8989!
如何避免此错误?