I use bundler to manage dependencies in my rails app, and I have a gem hosted in a git repository included as followed:
gem 'gem-name', :git => 'path/to/my/gem.git'
To update this gem, I execute bundle update
but it also updates all the gem mentioned in Gemfile. So what is the command to update just one specific gem?
To install it the usual way, run gem install bundler and RubyGems will install the latest version of Bundler. Now that you have Bundler 2 installed, you should know that Bundler will automatically switch between version 1 and version 2 based on your application’s Gemfile.lock.
It will probably fail if you update gems with significant dependencies ( rails ), or that a lot of gems depend on ( rack ). If a transparent update fails, your application will fail to boot, and bundler will print out an error instructing you to run bundle install .
The first step in upgrading to Bundler 2 is installing the Bundler 2 gem. To install it the usual way, run gem install bundler and RubyGems will install the latest version of Bundler.
In order to avoid this problem, when you update a gem, bundler will not update a dependency of that gem if another gem still depends on it. In this example, since rack-cache still depends on rack, bundler will not update the rack gem. This ensures that updating rails doesn't inadvertently break rack-cache.
Here you can find a good explanation on the difference between
Update both gem and dependencies:
bundle update gem-name
or
Update exclusively the gem:
bundle update --source gem-name
along with some nice examples of possible side-effects.
As @Tim's answer says, as of Bundler 1.14 the officially-supported way to this is with bundle update --conservative gem-name
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With