Skip to main content

Update just one gem with bundler [Resolved]

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?


Question Credit: sailor
Question Reference
Asked June 13, 2016
Posted Under: Programming
5 views
4 Answers

The way to do this is to run the following command:

bundle update --source gem-name

credit: dukz
Answered June 13, 2016
 
This is exactly what I needed, I have a private gem and only needs to update the gem itself without updating the dependencies after I made some changes to the private gem. – dragon who spits fire Jun 5 '13 at 1:47
 CanDoerz  3 years ago

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.

Note: I don't have enough points to put it as a comment... :)


credit: Jonathan Soifer
Answered June 13, 2016
 
Be careful, "updating gem and dependencies" means updating rails itself if it is a dependency and you probably don't want that. --source will only update the gem specified as parameter. So it is better in most situations. – 1.44mb Aug 31 '15 at 17:06
 CanDoerz  3 years ago

You simply need to specify the gem name on the command line:

bundle update gem-name

credit: Brandan
Answered June 13, 2016
 
bundle update gem-name will update the gem and "any of its dependencies". – yek Apr 19 '13 at 21:16
 CanDoerz  3 years ago
 
Strange. That's what bundle help update says to do. Which version of bundler are you using? – Brandan Jun 29 '12 at 14:44
 CanDoerz  3 years ago
 
This command seems to update all gems as well... – sailor Jun 29 '12 at 14:01
 CanDoerz  3 years ago

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.


credit: Kitto
Answered June 13, 2016
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA