简体   繁体   中英

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

I am trying to upgrade a gem ( hydra-derivatives ) to version 3.3.2 to see if it solves a bug we are having.

hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works .

What I've Tried

  1. bundle update --conservative hydra-derivatives but that only upgraded hydra-derivatives to 3.2.2 (& we want 3.3.2) and its dependency mini_magick from 4.5.1 to 4.8.0
  2. adding gem 'hydra-derivatives', '~> 3.3.2' but that gave me:

     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. I don't want to run bundle update hydra-derivatives because I don't want it to update a bunch of unnecessary gems and cause problems, hence why I read about --conservative

    a. I ran this anyway to test it, and it upgraded target gem to only 3.2.2 and 15 gems in total!

hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works.

You can still add this as an explicit dependency in your Gemfile:

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

then run

  bundle update hydra-derivatives --conservative

or

  bundle update hydra-works --conservative

Remove the hydra-works gem from your Gemfile. Either remove the gem and its dependencies by hand from the installed gem location or if you have the application in its own Ruby environment using rbenv or rvm run bundle clean --force .
Beware bundle clean --force will remove all of the gems in the Ruby version other than those specified in your Gemfile. If you have other applications that use the same version of Ruby you'll have to reinstall the gems for that application if they are different than what you are using in this application.

Add this to your Gemfile

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

And run bundle install

You should see the correct dependency version now in your Gemfile.lock

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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