Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-sync Gemfile.lock on changes to Gemfile

How to re-sync Gemfile.lock on changes to Gemfile.

Assuming I have 3 gems (gem1, gem2, gem3) in the Gemfile.

bundle install creates a Gemfile.lock file.

If I remove gem3 and run bundle install, I would like Gemfile.lock to be re-generated and gem3 removed from the rvm gemset. But it doesn't, how should I re-sync without dropping the gemset.

like image 453
Joe Avatar asked Oct 27 '12 16:10

Joe


People also ask

Can you update Gemfile lock?

Gemfile. lock is automatically generated when you run bundle install or bundle update . It should never be edited manually.

What is the difference between Gemfile and Gemfile lock?

The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.

Should Gemfile lock be checked in?

The Gem Development guide says that the Gemfile. lock file "should always be checked into version control." However, this is NOT true for Gems. For Applications, like your Rails apps, Sinatra apps, etc., it is true. The same does not go for Gems.


1 Answers

To bring the Gemfile.lock in line with Gemfile edits, run bundle check.

To bring the Gemfile.lock in line with both the Gemfile edits AND the latest compatible gems, run bundle update.


Related: This blogpost by viget has some good advice on Bundler Best Practices

like image 169
Prakash Murthy Avatar answered Sep 20 '22 15:09

Prakash Murthy