我按照 Michael Hartl 的 Rails 教程使用 Spork 运行 Guard,我遇到了这个问题。以下是错误消息:
20:45:58 - INFO - Starting Spork for RSpec, Test::Unit
20:45:58 - ERROR - Guard::Spork failed to achieve its <start>, exception was:
> [#B57790298EE3] ChildProcess::LaunchError: No such file or directory - bundle exec spork -p 8989
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/childprocess-0.3.9/lib/childprocess/unix/fork_exec_process.rb:54:in `l\aunch_process'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/childprocess-0.3.9/lib/childprocess/abstract_process.rb:72:in `start'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-spork-1.2.0/lib/guard/spork/spork_instance.rb:38:in `start'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-spork-1.2.0/lib/guard/spork/runner.rb:33:in `each'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-spork-1.2.0/lib/guard/spork/runner.rb:33:in `launch_sporks'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-spork-1.2.0/lib/guard/spork.rb:21:in `start'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:99:in `block in run_supervised_task'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:97:in `catch'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:97:in `run_supervised_task'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:54:in `block (2 levels) in run'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:175:in `block (3 levels) in scoped_gua\rds'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:174:in `each'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:174:in `block (2 levels) in scoped_gua\rds'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:173:in `catch'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:173:in `block in scoped_guards'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:172:in `each'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:172:in `scoped_guards'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:53:in `block in run'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/lumberjack-1.0.3/lib/lumberjack.rb:27:in `unit_of_work'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/runner.rb:52:in `run'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard.rb:189:in `block in start'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard.rb:365:in `block in within_preserved_state'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard.rb:362:in `synchronize'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard.rb:362:in `within_preserved_state'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard.rb:187:in `start'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/lib/guard/cli.rb:110:in `start'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
> [#B57790298EE3] /home/us/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.7.0/bin/guard:6:in `<top (required)>'
> [#B57790298EE3] ./bundler_stubs/guard:16:in `load'
> [#B57790298EE3] ./bundler_stubs/guard:16:in `<main>'
20:45:58 - INFO - Guard::Spork has just been fired
Spork 可以毫无问题地执行:
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
似乎是什么问题?childprocess-0.3.9 中是否存在错误?还是我的 Guardfile?下面是我的Guardfile:
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', :version => 2, :all_after_pass => false, :cli => '--drb' 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(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_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", (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : "spec/requests/#{m[1].s\ingularize}_pages_spec.rb")] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/}) do |m|
(m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
"spec/requests/#{m[1].singularize}_pages_spec.rb")
end
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb')
watch('test/test_helper.rb')
watch('spec/support/')
end