嗨我正在做一些编码并尝试
rake routes
并且出现了此错误消息,我不知道该怎么做
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.4.0. Prepending `bundle exec` to your command may solve this.
/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:34:in `block in setup'
/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:19:in `setup'
/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler.rb:121:in `setup'
/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler/setup.rb:7:in `<top (required)>'
/home/simplybel/projects/gamification/config/boot.rb:4:in `<top (required)>'
/home/simplybel/projects/gamification/config/application.rb:1:in `<top (required)>'
/home/simplybel/projects/gamification/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/simplybel/projects/gamification/config/boot.rb:4:in `<top (required)>'
/home/simplybel/projects/gamification/config/application.rb:1:in `<top (required)>'
/home/simplybel/projects/gamification/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
任何对此的帮助都会非常感激
答案 0 :(得分:27)
运行命令rails new MyNewProject
要在旧项目上修复它,我刚进入Gemfile.lock文件并搜索rake
。我找到了rake (10.3.2)
并将其替换为rake (10.4.2)
并为我修复了它。
答案 1 :(得分:19)
您通常不应手动编辑gemfile.lock
。如果您确实删除了该文件并从头开始重新启动,请确保指定gemfile
中的宝石版本,这样您就可以获得所期望的版本。对于这种情况:
$ bundle update rake
为我工作。
答案 2 :(得分:8)
此错误是因为您的gem文件使用的是不同版本的rake,因此您需要指定所需的rake版本,这样可以帮助您
bundle exec rake routes
答案 3 :(得分:3)
我今天刚遇到这个问题。我使用RubyMine构建了一个新项目,它安装了rake 10.4.2。对于我的工作,我必须使用10.3.2进行db:migrate。
RubyMine解决方案: 为了解决RubyMine中的问题,我打开了db:migrate的运行配置,转到Bundler选项卡并检查&#34;在bundle(bundle exec)的上下文中运行脚本&#34;
答案 4 :(得分:3)
如果您需要使用旧版本,请删除较新版本:
gem uninstall rake --version=<newer version>
在你的情况下:
gem uninstall rake --version=10.4.2
答案 5 :(得分:2)
您可以使用以下命令删除旧版本的gem:
gem uninstall rake --version=[Here version that you want to delete]
卸载后,只需正常使用rake routes
。
答案 6 :(得分:2)
这解决了我的问题。
答案 7 :(得分:0)
您可能想要更新gemfile.lock并将rake的版本从10.4.0更改为10.4.2,您可以像以前一样继续工作。
答案 8 :(得分:0)
命令
bundle exec rake routes
使其有效,但如果您选择正确版本的 rake 并在 Gemfile.lock
中进行更改,情况会更好答案 9 :(得分:-1)
我有两个答案:
bundle exec rake routes
gem update rake
然后rake routes