繁体   English   中英

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

[英]How does one upgrade a specific ruby gem to a specific (or the latest) version?

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

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

我试过的

  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因为我不希望它更新一堆不必要的 gem 并导致问题,因此我阅读了--conservative

    一个。 无论如何我运行它来测试它,它将目标 gem 升级到只有 3.2.2 和总共 15 个 gem!

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

您仍然可以在 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

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

将此添加到您的 Gemfile

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

并运行bundle install

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM