如何在gemfile中降级宝石?

时间:2018-12-05 16:52:07

标签: ruby-on-rails ruby rubygems bundler

我的Gemfile.lock中有这个

 sequel (5.15.0)

我想将gem版本降级到4.39.0,所以我进入Gemfile并在gem声明旁边添加一个版本:

gem 'sequel', '4.39.0'

并运行bundle exec bundle install

但这给了我

You have requested:
  sequel = 4.39.0

The bundle currently has sequel locked at 5.15.0.
Try running `bundle update sequel`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
Run `bundle install` to install missing gems

。 因此,我尝试运行bundle exec bundle update sequel,但它会返回相同的消息。 我如何降级宝石?

2 个答案:

答案 0 :(得分:3)

您只需要致电

bundle update sequel

前面没有bundle exec

您遇到的问题是由bundle exec评估您当前的Gemfile以便首先执行后一个命令引起的。在这里,它会找到Gemfile中指定的宝石与当前Gemfile.lock中的宝石之间的差异,然后进行补救。

通常,没有任何捆绑呼叫必须以bundle exec为前缀。

答案 1 :(得分:1)

首先尝试更新依赖的gem。如果您要降级,则可能是与其他gem的依赖断开。

最佳做法:

bundle update sequel dependent_gemnames...

如果您找不到依赖的gem,也可以尝试更新所有gem。但是注意!这可能会导致不良的副作用。

bundle update

最后一个最糟糕的选择是删除Gemfile.lock并运行

bundle install

这将重建您的完整Gem堆栈,并且应该能够创建一个有效的Gemfile.lock

相关问题