Should Gemfile.lock be included in .gitignore?

Update for 2022 from TrinitronX

Fast-forward to 2021 and now Bundler docs [web archive] now say to commit the Gemfile.lock inside a gem… ¯_(ツ)_/¯ I guess it makes sense for developers and ease of use when starting on a project. However, now CI jobs need to be sure to remove any stray Gemfile.lock files to test against other versions.

Legacy answer ~2010

Assuming you’re not writing a rubygem, Gemfile.lock should be in your repository. It’s used as a snapshot of all your required gems and their dependencies. This way bundler doesn’t have to recalculate all the gem dependencies each time you deploy, etc.

From cowboycoded’s comment below:

If you are working on a gem, then DO NOT check in your Gemfile.lock. If you are working on a Rails app, then DO check in your Gemfile.lock.

Here’s a nice article explaining what the lock file is.

Leave a Comment