Rails:您已经激活了rake 10.3.1,但是您的Gemfile需要rake 10.2.2(Gem :: LoadError) [英] Rails: You have already activated rake 10.3.1, but your Gemfile requires rake 10.2.2 (Gem::LoadError)

查看:51
本文介绍了Rails:您已经激活了rake 10.3.1,但是您的Gemfile需要rake 10.2.2(Gem :: LoadError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的错误:

rake aborted!
Gem::LoadError: You have already activated rake 10.3.1, but your Gemfile requires rake 10.2.2. Prepending `bundle exec` to your command may solve this.
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:34:in `block in setup'
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:19:in `setup'
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler.rb:119:in `setup'
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler/setup.rb:7:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/boot.rb:4:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/application.rb:1:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/boot.rb:4:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/application.rb:1:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

我无法执行任何抽佣任务,这似乎是我所有其他问题的根源.几天前,当我运行rake命令时,情况并非如此.谁能解释这里发生了什么以及如何使我的应用程序恢复正常?我撞墙了.另外,bundle exec不能为我解决问题的根源.过去我从来不需要这样做,现在仍然无法正常工作.

I can't run any rake tasks and this seems to be the root of all my other problems. It wasn't like this a couple days ago when I was running rake commands. Can anyone explain what's going on here and how to get my app back on track? I've hit a wall. Also, bundle exec doesn't fix the root of the problem for me. I never had to do that in the past and it's still not working now.

推荐答案

您应该查看bundle update并稍微更改工作流程.请参阅此问题以获得进一步的帮助.

EDIT 2: You should look at bundle update and change your workflow a little. Refer to this question for further assistance.

原始答案

这是一个简单的问题,当您的gemset的rake版本比您的Gemfile.lock提到的版本号新时,就会发生这种情况.

This is a simple issue which happens when your gemset has a rake version that is newer than the version number your Gemfile.lock mentions.

如错误消息中所述,您可以使用bundle exec使其正常工作.

As is mentioned in the error message, you can use bundle exec to get things working.

在这种情况下,我的解决方案是仅删除Gemfile.lock,如果我不太担心其他gem版本及其无止境的依赖关系.否则,您可以尝试仅删除Gemfile.lock中讨论rake版本的一行.运行bundle install,世界应该再次成为幸福的地方. ( edit 2 :运行bundle update --source代替此.不要这样做.)

My solution in such cases is to just remove Gemfile.lock if I am not too worried other gem versions and their endless dependencies. Otherwise, you can try just removing the one line in Gemfile.lock which talks about the version of rake. run bundle install and the world should be a happy place again. (edit 2: Run bundle update --source instead of this. Don't do this.)

PS:尝试使用宝石集,并为不同项目使用rvm 来组织宝石.

PS: Try using gemsets and organising your gems with rvm for different projects.

修改

我现在更喜欢使用 rbenv 来管理安装,并且项目的所有gem都使用vendor/bundle bundle install --path选项.以后用bundle exec限制每个gem命令.

I prefer using rbenv now for managing installations and all gems for a project reside in vendor/bundle using bundle install --path option. Later scope every gem command with bundle exec.

因此,rails s变为bundle exec rails s.在我看来,多打字是更好的选择,如果这意味着事情将保持整洁并且不会发生诸如此类的冲突.

Hence, rails s becomes bundle exec rails s. A little more typing is, in my opinion, better if it means that things will remain clean and conflicts such as this one don't happen.

这篇关于Rails:您已经激活了rake 10.3.1,但是您的Gemfile需要rake 10.2.2(Gem :: LoadError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆