【发布时间】:2014-01-03 23:25:56
【问题描述】:
我开始收到此错误,并希望找到解决方法:
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
我在 RubyMine 中运行它。我可以在我的 Gemfile.lock 中看到它指定 10.1.0。我可以手动将我的 Gemfile.lock 更新到 10.1.1 吗?
如果我这样做:
$gem list
....
rake (10.1.1, 10.1.0, 10.0.4, 0.9.2.2)
所以我不知道为什么它不仅仅适用于 10.1.0?
这是 RubyMine 的完整输出:
/Users/jt/.rvm/rubies/ruby-1.9.3-p448/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/jt/.rvm/gems/ruby-1.9.3-p448/bin/rake spec
Testing started at 3:15 PM ...
rake aborted!
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
/Users/jt/repos/app/config/boot.rb:6:in `<top (required)>'
/Users/jt/repos/app/config/application.rb:1:in `<top (required)>'
/Users/jt/repos/app/Rakefile:5:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
(See full trace by running task with --trace)
Process finished with exit code 1
【问题讨论】:
-
转到 Edit Configurations > Bundler > check Run the script in the context of the bundle (bundle exec),重启并检查结果。
-
您是否使用 rvm 或 rbenv 管理您的 ruby 版本?如果您使用的是 rvm,您是否也在使用 gemsets?检查您的 Rubymine 设置以确保它在您的项目中使用与您在命令行中使用的相同的 ruby/gemset 环境。
-
thx 理想情况下,我可以取消激活 rake 10.1.1 吗?我真的只是希望它保持原来的样子。使用 bundle exec 有效但很痛苦
-
那么你在使用 gemsets 吗?似乎您在一个 gemset 中拥有所有 gem,这可能就是您必须在 bundle exec 的上下文中运行脚本的原因。我有几个项目(所有项目都有不同的 gemsets),它们在 RubyMine 中运行良好,无需检查该选项。
标签: ruby-on-rails ruby-on-rails-3.2 bundler