Skip to content
Latchkey

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.

bundler
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

  1. Delete the corrupt Gemfile.lock.
  2. Run bundle install to rebuild it cleanly from the Gemfile.
  3. Review the diff and commit the regenerated lockfile.
Terminal
rm Gemfile.lock
bundle install
git add Gemfile.lock

Resolve lockfile merge conflicts with Bundler

Let Bundler reconcile a conflicted lockfile instead of editing it by hand.

Terminal
git checkout --theirs Gemfile.lock
bundle install

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →