Reputation: 8034
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?
Upvotes: 302
Views: 190869
Reputation: 2891
With newer versions of bundler (>= 1.14, released in March 2017) it's:
bundle update --conservative gem-name
Conservative updates
The conservative flag allows bundle update --conservative GEM to update the version of GEM, but prevents Bundler from updating the versions of any of the gems that GEM depends on, similar to changing a gem’s version number in the Gemfile and then running bundle install.
See bundler 1.14 release notes or Bundler 1.14: So many fixes blog post for more info.
Upvotes: 73
Reputation: 722
If nothing happens with bundle update gem-name
it's maybe due to having as a global config do not touch lock files
, you can disable this:
bundle config set frozen false
Upvotes: 0
Reputation: 5150
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
.
Upvotes: 487
Reputation: 2008
If you want to update a single gem to a specific version:
bundle update
> ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
> gem -v
3.0.3
> bundle -v
Bundler version 2.1.4
Upvotes: 0
Reputation: 188
bundler update --source gem-name
will update the revision hash in Gemfile.lock which you can compare with the last commit hash of that git branch (master by default).
GIT
remote: [email protected]:organization/repo-name.git
revision: c810f4a29547b60ca8106b7a6b9a9532c392c954
can be found at github.com/organization/repo-name/commits/c810f4a2
(I used shorthand 8 character commit hash for the url)
Upvotes: 0
Reputation: 4783
bundle update gem-name [--major|--patch|--minor]
This also works for dependencies.
Upvotes: 8
Reputation: 1190
I've used bundle update --source
myself for a long time but there are scenarios where it doesn't work. Luckily, there's a gem called bundler-patch
which has the goal of fixing this shortcoming.
I also wrote a short blog post about how to use bundler-patch
and why bundle update --source
doesn't work consistently. Also, be sure to check out a post by chrismo that explains in great detail what the --source
option does.
Upvotes: 3
Reputation: 2155
The way to do this is to run the following command:
bundle update --source gem-name
Upvotes: 199
Reputation: 14983
You simply need to specify the gem name on the command line:
bundle update gem-name
Upvotes: 25