Skip to content
Latchkey

Bundler "Your bundle is locked to" - Fix Lockfile Drift in CI

Bundler found that your Gemfile and Gemfile.lock disagree. In frozen or deployment mode - the default in CI - that mismatch is a hard failure rather than a silent re-resolve.

What this error means

bundle install fails reporting the bundle is locked to a version that is missing, or that the dependencies in your Gemfile changed and the lockfile does not reflect it. It surfaces after someone edits the Gemfile without re-running bundle.

bundler output
Your bundle is locked to nokogiri (1.15.0), but that version could not
be found in any of the sources listed in your Gemfile. ...
Run `bundle install` elsewhere and add the updated Gemfile.lock to version control.

Common causes

Gemfile edited without re-locking

A change to the Gemfile (added, removed, or bumped gem) was committed without regenerating Gemfile.lock, so the two disagree and frozen mode refuses to proceed.

A locked version no longer exists

The exact version pinned in Gemfile.lock was yanked from the source, so Bundler cannot install what the lockfile demands.

How to fix it

Regenerate and commit the lockfile locally

Re-resolve on a machine with network access, then commit the updated lockfile.

Terminal
bundle install
git add Gemfile.lock && git commit -m "Update Gemfile.lock"

Update only the affected gem

If a single locked version vanished, refresh just that gem instead of the whole lockfile.

Terminal
bundle update nokogiri

How to prevent it

  • Always run bundle install after editing the Gemfile and commit the lockfile.
  • Add a bundle lock --check (or bundle-audit) step to CI to catch drift in PRs.
  • Keep deployment/frozen mode on in CI so drift fails loudly instead of silently re-resolving.

Related guides

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