Bundler "Your Gemfile.lock is corrupt" in CI
Bundler parsed Gemfile.lock and found it internally inconsistent: a gem referenced in one section is missing from another, or a section is malformed. This almost always follows a bad merge or a manual edit.
What this error means
bundle install aborts with "Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES section: X" or a similar structural complaint about the lockfile.
Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'puma'Common causes
A merge conflict was resolved incorrectly
Resolving a Gemfile.lock conflict by hand dropped or duplicated entries, leaving GEM, DEPENDENCIES, and PLATFORMS out of agreement.
The lockfile was edited manually
Someone changed a version or removed a line directly in Gemfile.lock instead of via Bundler, breaking its internal references.
How to fix it
Regenerate the lockfile from the Gemfile
- Delete the corrupt Gemfile.lock.
- Run bundle install to rebuild it cleanly from the Gemfile.
- Review the diff and commit the regenerated lockfile.
rm Gemfile.lock
bundle install
git add Gemfile.lockResolve lockfile merge conflicts with Bundler
Let Bundler reconcile a conflicted lockfile instead of editing it by hand.
git checkout --theirs Gemfile.lock
bundle installHow to prevent it
- Never hand-edit Gemfile.lock; change versions via Bundler.
- Resolve lockfile merge conflicts by re-running bundle install.
- Keep the lockfile committed so regeneration is auditable.