Skip to content
Latchkey

Bundler "the lockfile ... out of sync" with --deployment in CI

In deployment or frozen mode Bundler will not modify Gemfile.lock. It compared your Gemfile against the committed lockfile, found they differ, and refused to install because it is not allowed to update the lock in CI.

What this error means

bundle install --deployment (or with BUNDLE_FROZEN=true) fails listing gems added to or removed from the Gemfile, ending with "you should run bundle install elsewhere and add the updated Gemfile.lock to version control."

bundler
The dependencies in your gemfile changed, but the lockfile can't be updated because
frozen mode is set

You have added to the Gemfile:
* rack-cors

Run `bundle install` elsewhere and add the updated Gemfile.lock to version control.

Common causes

The Gemfile was edited without relocking

A gem was added or removed in the Gemfile but Gemfile.lock was not regenerated, so frozen mode sees a mismatch.

The lockfile change was not committed

bundle install ran locally and updated the lock, but the updated Gemfile.lock was never committed, so CI checks out the old one.

How to fix it

Regenerate and commit the lockfile

  1. Run bundle install locally to update Gemfile.lock to match the Gemfile.
  2. Commit the updated Gemfile.lock alongside the Gemfile change.
  3. Re-run CI so deployment mode finds them in sync.
Terminal
bundle install
git add Gemfile Gemfile.lock

Verify both files are tracked

Confirm Gemfile.lock is committed and not ignored, so the runner installs against the same lock you generated.

Terminal
git status --short Gemfile.lock
git check-ignore Gemfile.lock || echo tracked

How to prevent it

  • Run bundle install and commit Gemfile.lock with every Gemfile edit.
  • Never add Gemfile.lock to .gitignore for applications.
  • Keep --deployment/frozen on in CI so drift fails fast.

Related guides

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