is it desirable to remove Gemfile.lock?

It is recommended to keep the Gemfile.lock.

Gemfile.lock keeps track of all inter gem dependency, and has exact gem versions to be used.

If you are deploying the same project at multiple locations, it is a definite way of ensuring that all your copies have the same copy of the gems, and hence the environment is identical on each machine.

Without it, bundler will install the latest versions of the gems, and that might break things if a newer version of a gem doesn't support a feature/format you are working in.

For further reading on Gemfile and Gemfile.lock, check out this and this


Does bundle install take specific gems in my Gemfile or Gemfile.lock?

bundle install looks first into gemfile.lock, then looks into gemfile to generate a valid gem list, checks, tries to resolve the dependencies, and then install/update the gems.

My Gemfile and Gemfile.lock are not the same.

They don't need to be the same. gemfile.lock is a specific file to keep the gems' state at the time of running bundle install/update.

Do I have to remove Gemfile.lock?

You can, but then bundle install will generate gemfile.lock again. Then, you could really lose and break all gem dependencies, and might need to resolve them manually.

As an investigation procedure, you can copy old gemfile.lock to a secluded place, then regenerate gemfile.lock, and compare both with diff


Gemfile.lock has the exact versions of the gems to be used. Some of them would not be mentioned in your Gemfile and bundler will refer the lock file for specific version.

If you remove the lock file it will either use the local gem if present else download the latest version of the gems.