Calling bundle update GEMNAME
will update a lot more gems than you think. E.g. when you do this:
bundle update cucumber-rails
... you might think this will only update cucumber-rails
. But it actually updates cucumber-rails and all of its dependencies. This will explode in your face when one of these dependencies release a new version with breaking API changes. Which is all the time.
In the example above updating cucumber-rails
will give you Capybara 2.0 (because capybara
is a dependency of cucumber-rails
),
which will break all your tests
Show archive.org snapshot
.
Bundler >= 1.14
Show archive.org snapshot
has a --conservative
flag. Using the conservative flag allows bundle update GEM to update the version of GEM, but prevents Bundler from updating the versions of any of the gems that GEM depends on.
For the example above you would say:
bundle update cucumber-rails --conservative
If Bundler complains of a single dependency that it cannot resolve this way, simply add it to the command:
bundle update cucumber-rails capybara --conservative
The options below might be relevant if you're stuck with Bundler < 1.14:
This will work if all dependencies for the update are already satisfied.
Gemfile.lock
bundle install
and see if that workedThis will work if the gem has no shared dependencies with other gems.
Gemfile
with , '=1.2.3'
bundle install
bundle install
once moreThis should always work.
bundle update GEMNAME
git diff Gemfile.lock
and notice all the updates you didn't wantGemfile.lock
you don't want (manually or by staging changed lines one-by-one), leaving only the desired updates.bundle install
and see if that workedThere are
persistent rumors
Show archive.org snapshot
that you can update a single gem by calling bundle update --source GEMNAME
. However no one seems to know how and why this works, it's not a documented feature of Bundler. It might be an unintended side effect of something else.
I believe this command will try to update GEMNAME
and GEMNAME
only. If this leads to unmatched dependencies to to other locked gems, it will fail.
If you use this option, be sure to git diff
your Gemfile.lock
to see if the changes are what you expected.