Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gemfile.lock Use in Rails?

Tags:

What is the purpose of "Gemfile.lock" in Rails? I have been searching around for but could not find a satisfactory answer.

like image 320
Nitish Upreti Avatar asked Feb 09 '12 09:02

Nitish Upreti


People also ask

What is Gemfile 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.

What is the use of Gemfile?

Your gemfile is a list of all gems that you want to include in the project. It is used with bundler (also a gem) to install, update, remove and otherwise manage your used gems. These gems belong to development environment and the test environment since they are for testing the application.

What is Gemfile in Ruby on rails?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

Should I include Gemfile lock?

You can (and should) specify versions of gems in your Gemfile but without the Gemfile. lock being included in Git. Then nobody else will get to benefit from your work of checking that the updated Gems still work. You should check your Gemfile for updates frequently and bundle update where appropriate.


1 Answers

You should read all the documentation from the bundler gem: http://gembundler.com/

THE GEMFILE.LOCK

When you run bundle install, Bundler will persist the full names and versions of all gems that you used (including dependencies of the gems specified in the Gemfile(5)) into a file called Gemfile.lock.

Bundler uses this file in all subsequent calls to bundle install, which guarantees that you always use the same exact code, even as your application moves across machines.

Because of the way dependency resolution works, even a seemingly small change (for instance, an update to a point-release of a dependency of a gem in your Gemfile(5)) can result in radically different gems being needed to satisfy all dependencies.

As a result, you SHOULD check your Gemfile.lock into version control. If you do not, every machine that checks out your repository (including your production server) will resolve all dependencies again, which will result in different versions of third-party code being used if any of the gems in the Gemfile(5) or any of their dependencies have been updated.

like image 143
fuzzyalej Avatar answered Oct 12 '22 03:10

fuzzyalej