rake或任何其他rake命令无法正常工作

use*_*185 14 rake ruby-on-rails

嗨我正在做一些编码并试图

rake routes
Run Code Online (Sandbox Code Playgroud)

并出现此错误消息,我不知道该怎么做

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)
Run Code Online (Sandbox Code Playgroud)

任何有关这方面的帮助将非常感激

Eri*_*ric 27

运行命令后,我在旧项目中遇到此问题 rails new MyNewProject

为了在旧项目上修复它我刚进入Gemfile.lock文件并搜索rake.我发现rake (10.3.2)并替换了它rake (10.4.2)并为我修复了它.


MCB*_*MCB 19

您通常不应手动编辑gemfile.lock.如果您确实删除了该文件并从头开始重新启动,请确保gemfile指定了您的宝石版本,这样您就可以获得所期望的版本.对于这种情况:

$ bundle update rake

为我工作.


rde*_*an1 8

此错误是因为您的gem文件使用的是不同版本的rake,因此您需要指定所需的rake版本,这样可以帮助您

 bundle exec rake routes
Run Code Online (Sandbox Code Playgroud)