1

bundle update rails今天在一个基于 RVM 的应用程序上运行,并在此过程中将 Rake 更新为 10.0.3。现在我不能再运行rake spec了,因为它试图使用系统 Ruby 而不是正确的 RVM Ruby。

这是输出:

$ bundle exec rake spec -b
/usr/local/lib/ruby -S rspec ./spec/controllers/articles_controller_spec.rb ...
rake aborted!
/usr/local/lib/ruby -S rspec ./spec/controllers/articles_controller_spec.rb ...
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rspec-core-2.12.2/lib/rspec/core/rake_task.rb:156:in `run_task'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rspec-core-2.12.2/lib/rspec/core/rake_task.rb:124:in `initialize'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:61:in `verbose'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rspec-core-2.12.2/lib/rspec/core/rake_task.rb:122:in `send'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rspec-core-2.12.2/lib/rspec/core/rake_task.rb:122:in `initialize'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/task.rb:228:in `execute'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/task.rb:166:in `invoke_with_call_chain'
/Users/brandan/.rvm/rubies/ruby-1.8.7-p174/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:73:in `run'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/gems/rake-10.0.3/bin/rake:33
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/bin/rake:19:in `load'
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/bin/rake:19
Tasks: TOP => spec

请注意,RSpec 正在尝试使用外壳/usr/local/lib/ruby而不是 RVM 安装的 Ruby 的正确路径。如果我只是从命令行运行rspec,一切都会通过:

$ bundle exec rspec
.....................................

Finished in 1.81 seconds
37 examples, 0 failures

我降级到 Rake 10.0.2 并没有遇到这个问题,我可以在本地机器上类似 Ruby 版本的其他应用程序中使用 Rake 10.0.3 复制它。

问题似乎Rake::TaskLib::RUBY是定义不正确:

$ bundle exec ruby -e 'require "rake/tasklib"; puts Rake::TaskLib::RUBY'
/usr/local/lib/ruby

知道我的环境有什么问题吗?

OS X 10.8.2
RVM 1.18.5

编辑:更多环境:

$ echo $PATH
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/bin:/Users/brandan/.rvm/gems/ruby-1.8.7-p174@global/bin:/Users/brandan/.rvm/rubies/ruby-1.8.7-p174/bin:/Users/brandan/.rvm/bin:/usr/local/heroku/bin:/Users/brandan/bin:.gem/ruby/1.8/bin:/usr/local/git/bin:/usr/local/mysql/bin:/usr/local/pear/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$ which -a ruby
/Users/brandan/.rvm/rubies/ruby-1.8.7-p174/bin/ruby
/usr/bin/ruby
$ which -a bundle
/Users/brandan/.rvm/gems/ruby-1.8.7-p174@bcl/bin/bundle
/Users/brandan/.rvm/bin/bundle
/usr/bin/bundle
$ head -n 1 $(which bundle)
#!/Users/brandan/.rvm/rubies/ruby-1.8.7-p174/bin/ruby
4

1 回答 1

1

看起来您可能会受到此更改的影响https://github.com/jimweirich/rake/commit/968682759b3b65e42748cd2befb2ff3e982272d9#L0R9

确保取消设置变量:

unset RUBY
于 2013-02-11T00:45:58.623 回答