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

问题描述 投票:0回答:2

我正在尝试将 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`
    
  3. 我不想运行

    bundle update hydra-derivatives
    因为我不希望它更新一堆不必要的宝石并引起问题,因此我为什么阅读
    --conservative

    一个。我还是运行了这个来测试它,它把目标宝石升级到只有 3.2.2 和总共 15 个宝石!

ruby-on-rails ruby rubygems bundler
2个回答
2
投票

hydra-derivatives 不是 Gemfile gem;它被捆绑为另一个 gem 的依赖项,称为 hydra-works。

您仍然可以将其添加为 Gemfile 中的显式依赖项:

  # only restrict the version if you know of an incompatibility
  gem 'hydra-derivatives' , '~> 3.3'

然后跑

  bundle update hydra-derivatives --conservative

  bundle update hydra-works --conservative

--conservative
命令中添加选项
bundle update
,确保您不会更新任何其他不相关的 gem。这有助于保持变更的重点和可管理性。


-1
投票

从 Gemfile 中删除 hydra-works gem。 从安装的 gem 位置手动删除 gem 及其依赖项,或者如果您在自己的 Ruby 环境中使用

rbenv
rvm
运行
bundle clean --force
.
当心
bundle clean --force
将删除 Ruby 版本中除了 Gemfile 中指定的所有 gem。如果您有其他应用程序使用相同版本的 Ruby,如果它们与您在此应用程序中使用的不同,则必须为该应用程序重新安装 gem。

将此添加到您的 Gemfile

gem 'hydra-derivatives', '~> 3.3.2'
gem 'hydra-works'

然后跑

bundle install

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

© www.soinside.com 2019 - 2024. All rights reserved.