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)

查看:14
本文介绍了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 任务,这似乎是我所有其他问题的根源.几天前,当我运行 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.

如果我不太担心其他 gem 版本及其无尽的依赖关系,我在这种情况下的解决方案是删除 Gemfile.lock.否则,您可以尝试仅删除 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:尝试使用 gemset 并使用 rvm 组织您的 gem 用于不同的项目.

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天全站免登陆