Ruby-on-rails 耙子中止!您已经激活了 rake 10.0.2,但是您的 Gemfile 需要 rake 0.9.2.2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13489953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:02:57  来源:igfitidea点击:

rake aborted! You have already activated rake 10.0.2, but your Gemfile requires rake 0.9.2.2

ruby-on-railsrake

提问by Andy

I am trying to do "rake db:migrate" and it is giving me this error.

我正在尝试执行“rake db:migrate”,它给了我这个错误。

Andy:AcademyAir Andy$ rake db:migrate
/Users/Andy/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.2.2/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr in PATH, mode 040777
rake aborted!
You have already activated rake 10.0.2, but your Gemfile requires rake 0.9.2.2. Using bundle exec may solve this.
/Users/Andy/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.2.2/lib/bundler/runtime.rb:31:in `block in setup'
/Users/Andy/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.2.2/lib/bundler/runtime.rb:17:in `setup'
/Users/Andy/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.2.2/lib/bundler.rb:116:in `setup'
/Users/Andy/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.2.2/lib/bundler/setup.rb:7:in `<top (required)>'
/Users/Andy/Desktop/AcademyAir/config/boot.rb:6:in `<top (required)>'
/Users/Andy/Desktop/AcademyAir/config/application.rb:1:in `<top (required)>'
/Users/Andy/Desktop/AcademyAir/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

回答by Dipak Panchal

Try this bundle exec rake db:migrate

尝试这个 bundle exec rake db:migrate

Remove rake 10.0.2 gem

移除 rake 10.0.2 gem

By using gem uninstall rakeand remove 10.0.2version of rake gem

通过使用gem uninstall rake和删除10.0.2rake gem 的版本

And Then Try rake db:migrate

然后尝试 rake db:migrate

Why Error comes: In you gem list two version (10.0.2 and 0.9.2.2) of rake gem install so that this error comes.*

为什么会出现错误:在您的 gem 中列出了 rake gem 安装的两个版本(10.0.2 和 0.9.2.2),因此会出现此错误。*

Another Solution is you can do bundle update

另一个解决方案是你可以做 bundle update

回答by csoria

For me, I just ran bundle updateand everything works right again.

对我来说,我只是跑了bundle update,一切又正常了。

回答by user1817421

I was able to solve this by opening up Gemfile and changing gem 'rake', '~> 0.9.2.2'to gem 'rake', '~> 10.0.1'

我能够通过打开 Gemfile 并更改gem 'rake', '~> 0.9.2.2'gem 'rake', '~> 10.0.1'

回答by Sandeep Roniyaar

In your Gemfile, explicitly set the latest rake version by:

在您的 中Gemfile,通过以下方式明确设置最新的 rake 版本:

gem 'rake', '~> 10.0.1'

And then run

然后运行

$ bundle update rake

Then try

然后试试

回答by Rogério Alexandre

I've just ran into the same problem.

我刚刚遇到了同样的问题。

  1. I inserted in my gemfilen gem 'rake', '~> 10.0.1' [in your case it should be '10.0.2']
  2. I deleted my gemfile lock
  3. I ran rake db:migration again and it worked.
  1. 我插入了我的 gemfilen gem 'rake', '~> 10.0.1' [在你的情况下它应该是 '10.0.2']
  2. 我删除了我的 gemfile 锁
  3. 我再次运行 rake db:migration 并且它起作用了。

I got this tip here: Activated Ruby RAKE 10.0.1, require 10.0.0

我在这里得到了这个提示:Activated Ruby RAKE 10.0.1,需要 10.0.0

Update:In my case I didn't have rake duplicated. I just have in my gems the 10.0.1 version.

更新:就我而言,我没有重复使用耙子。我的 gems 中只有 10.0.1 版本。

回答by yellowaj

Solved the same issue by running:

通过运行解决了同样的问题:

bundle update

This will update your rake gem to the latest version and allow you to run the migration.

这会将您的 rake gem 更新到最新版本并允许您运行迁移。

If you are using a gemset: be sure to run bundle installafter you've updated rake to update your local gemset as well.

如果您使用的是 gemset:请确保bundle install在更新 rake 后运行以更新您的本地 gemset。

回答by mrded

It happens because you are using rakefrom the system. (latest version by default) The solution is use follow command:

发生这种情况是因为您正在使用系统中的rake。(默认最新版本)解决方法是使用以下命令:

bundle exec rake db:migrate

Also, you can create alias. Because this command is too big and difficult to write.

此外,您可以创建别名。因为这个命令太大,很难写。

echo "alias be='bundle exec'" >> ~/.bash_profile
source ~/.bash_profile

Then you can use follow short command:

然后您可以使用以下简短命令:

be rake db:migrate

回答by Richard Chen

change the version which located both in the gemfile and gemlock to the version number shown in the console, it will be done

将位于 gemfile 和 gemlock 中的版本更改为控制台中显示的版本号,它将完成