如何将特定的 ruby​​ gem 升级到特定(或最新)版本?

Rud*_*ils 11 ruby rubygems ruby-on-rails bundler

我正在尝试将 gem ( hydra-derivatives) 升级到版本3.3.2,看看它是否解决了我们遇到的错误。

Hydra-derivatives不是Gemfile gem;它作为另一个 gem 的依赖项捆绑在一起,称为hydra-works.

我尝试过的

  1. bundle update --conservative hydra-derivatives但这只是将 Hydra-derivatives 升级到 3.2.2(我们想要 3.3.2),并且它的依赖项mini_magick从 4.5.1 升级到 4.8.0
  2. 添加gem 'hydra-derivatives', '~> 3.3.2'但这给了我:

    You have requested:
      hydra-derivatives ~> 3.3.2
    
    The bundle currently has hydra-derivatives locked at 3.2.1.
    Try running `bundle update hydra-derivatives`
    
    If you are updating multiple gems in your Gemfile at once,
    try passing them all to `bundle update`
    
    Run Code Online (Sandbox Code Playgroud)
  3. 我不想运行,bundle update hydra-derivatives因为我不想让它更新一堆不必要的宝石并导致问题,因此我为什么读到--conservative

    A。无论如何我运行这个来测试它,它把目标宝石升级到只有 3.2.2 和总共 15 个宝石!

小智 -1

从 Gemfile 中删除 Hydra-works gem。从安装的 gem 位置手动删除 gem 及其依赖项,或者如果您在自己的 Ruby 环境中使用rbenvrvm 运行该应用程序bundle clean --force
Bewarebundle clean --force将删除 Ruby 版本中除 Gemfile 中指定的所有 gem。如果您有其他应用程序使用相同版本的 Ruby,则必须重新安装该应用程序的 gem(如果它们与您在此应用程序中使用的不同)。

将其添加到您的 Gemfile 中

gem 'hydra-derivatives', '~> 3.3.2'
gem 'hydra-works'
Run Code Online (Sandbox Code Playgroud)

并运行bundle install

您现在应该在 Gemfile.lock 中看到正确的依赖版本