我在终端运行了这个rake routes命令,但没有工作,但是几天前他就开始工作了。请检查
jaskaran@jaskaran-Vostro-1550:~/rails_project$ rake routes
rake aborted!
Gem::LoadError: You have already activated rake 10.3.2, but your Gemfile requires rake 10.2.2. Prepending `bundle exec` to your command may solve this.
/home/jaskaran/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:34:in `block in setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:19:in `setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/bundler.rb:120:in `setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/bundler/setup.rb:7:in `<top (required)>'
/home/jaskaran/rails_project/config/boot.rb:4:in `<top (required)>'
/home/jaskaran/rails_project/config/application.rb:1:in `<top (required)>'
/home/jaskaran/rails_project/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/jaskaran/rails_project/config/boot.rb:4:in `<top (required)>'
/home/jaskaran/rails_project/config/application.rb:1:in `<top (required)>'
/home/jaskaran/rails_project/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
答案 0 :(得分:8)
尝试运行bundle exec rake routes
以确保加载正确版本的Rake。
答案 1 :(得分:3)
您需要将宝石更新为最新版本:bundle update
答案 2 :(得分:1)
Rake版本似乎有所不同。因此,请将其作为bundle exec rake routes
运行。它应该工作。
答案 3 :(得分:1)
问题的正确解决方法是按照其他人的建议使用bundle exec
来加载应用所期望的Rake版本。您可能还希望避免始终使用bundle exec
运行Rake命令。你可以
1)[推荐]更新你的应用程序以使用与全局运行相同版本的rake(10.3.2,这是最新版本)
或
2)[不是真的推荐]从全局gems卸载版本10.3.2(实际上,任何大于你想要的版本)并安装版本10.2.2(你的应用当前使用的版本)
rvm @global do gem uninstall rake
rvm @global do gem install rake --version 10.2.2