Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update just one gem with bundler

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?

like image 548
sailor Avatar asked Oct 19 '22 13:10

sailor


People also ask

How to install bundler 2 on RubyGems?

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.

Why does bundler fail when I update gems?

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 .

How do I upgrade to bundler 2?

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.

Why is bundler not updating my rack-cache?

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.


1 Answers

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.

Update

As @Tim's answer says, as of Bundler 1.14 the officially-supported way to this is with bundle update --conservative gem-name.

like image 191
mseebacher Avatar answered Nov 03 '22 02:11

mseebacher