Skip to content
Latchkey

Bundler "locked to a different version of bundler" (BUNDLED WITH) in CI

Gemfile.lock records the Bundler version that wrote it in the BUNDLED WITH section. The runner has a different Bundler, so it either tries to activate the locked version (which may be absent) or warns about the mismatch.

What this error means

bundle install warns or fails with "Your lockfile was generated with a different version of Bundler" or "Could not find 'bundler' (X) required by your Gemfile.lock", referencing the BUNDLED WITH version.

bundler
Warning: the running version of Bundler (2.5.6) is older than the version that
created the lockfile (2.5.11). We suggest you to upgrade to the version that created
the lockfile by running `gem install bundler:2.5.11`.

Common causes

The runner Bundler differs from BUNDLED WITH

The lockfile was generated by a newer or older Bundler than the one preinstalled on the runner image.

The locked Bundler is not installed

Bundler tries to self-activate the BUNDLED WITH version, but that exact version is not present, so it cannot proceed.

How to fix it

Install the bundler version the lockfile names

  1. Read the BUNDLED WITH version at the bottom of Gemfile.lock.
  2. Install that exact bundler before bundle install.
  3. Run the install so the locked and active versions match.
Terminal
gem install bundler -v 2.5.11
bundle _2.5.11_ install

Let setup-ruby read the lockfile bundler

ruby/setup-ruby installs the BUNDLED WITH version automatically when configured to do so.

.github/workflows/ci.yml
- uses: ruby/setup-ruby@v1
  with:
    bundler: Gemfile.lock

How to prevent it

  • Install the lockfile BUNDLED WITH version in CI.
  • Keep the local and CI bundler versions aligned.
  • Use setup-ruby to provision the matching bundler.

Related guides

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