Rake 10.0.3在RVM中运行错误版本的Ruby

时间:2013-02-09 16:42:45

标签: ruby rspec rake rvm

我今天在基于RVM的应用程序上运行bundle update rails,并在此过程中将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发送shell而不是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

1 个答案:

答案 0 :(得分:1)

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

的影响

确保取消设置变量:

unset RUBY