同一台机器上的多个 Rails vers + rake
Multiple Rails vers on same machine + rake
我已经 运行使用 Rails 3.2 和 Ruby 1.9.3 一段时间了。最近我添加了 Rails 5.1 和 Ruby 2.4.
我用rvm安装了Ruby2.4.
今天我有机会 cd 到我的一个旧项目和 运行 rake db:migrate
,我收到以下消息:
Gem::LoadError: You have already activated rake 12.0.0, but your Gemfile requires rake 0.9.2.2. Prepending `bundle exec` to your command may solve this.
前置 'bundle exec' 确实解决了问题,但据我所知,我想了解发生了什么。我认为项目中 Gem 文件的全部意义在于锁定所需的宝石。
所以我机器上的某个地方显然还有 rake 0.9.2.2 但为什么我的命令 'rake db:migrate' 没有自动使用它?
原因:某些 gem 可能已将 rake gem 锁定到那个 version.You 正在将其作为内部版本的 rake gem锁定文件与您已经安装的不同。
解决方案1:
bundle update
解决方案2:
编辑gem锁文件。打开 Gemfile.lock 并更改
rake (0.9.2.2) to rake (12.0.0)
解决方案3:
删除 Gemfile.lock 和 运行 bundle install
一旦 again.This 将创建
Gemfile.lock 再一次。
我已经 运行使用 Rails 3.2 和 Ruby 1.9.3 一段时间了。最近我添加了 Rails 5.1 和 Ruby 2.4.
我用rvm安装了Ruby2.4.
今天我有机会 cd 到我的一个旧项目和 运行 rake db:migrate
,我收到以下消息:
Gem::LoadError: You have already activated rake 12.0.0, but your Gemfile requires rake 0.9.2.2. Prepending `bundle exec` to your command may solve this.
前置 'bundle exec' 确实解决了问题,但据我所知,我想了解发生了什么。我认为项目中 Gem 文件的全部意义在于锁定所需的宝石。
所以我机器上的某个地方显然还有 rake 0.9.2.2 但为什么我的命令 'rake db:migrate' 没有自动使用它?
原因:某些 gem 可能已将 rake gem 锁定到那个 version.You 正在将其作为内部版本的 rake gem锁定文件与您已经安装的不同。
解决方案1:
bundle update
解决方案2:
编辑gem锁文件。打开 Gemfile.lock 并更改
rake (0.9.2.2) to rake (12.0.0)
解决方案3:
删除 Gemfile.lock 和 运行 bundle install
一旦 again.This 将创建
Gemfile.lock 再一次。