Skip to content
Latchkey

Bundler "Your Ruby version is X, but your Gemfile specified Y"

The Gemfile (or .ruby-version) declares a required Ruby, and the interpreter on the runner is a different version. Bundler refuses to continue until the running Ruby matches the requirement.

What this error means

bundle install or bundle exec aborts immediately stating your Ruby version differs from what the Gemfile specified. The interpreter works; it is simply not the version the project pins.

bundler output
Your Ruby version is 3.2.2, but your Gemfile specified 3.3.0

Common causes

Runner provisions a different Ruby

The CI step did not pin a Ruby, so the image default (e.g. 3.2.2) is used instead of the version the Gemfile requires (3.3.0).

Gemfile ruby requirement out of date

The Gemfile pins an exact Ruby that no longer matches what the team runs, so every runner with a newer/older Ruby fails.

How to fix it

Pin the Ruby version in CI

Provision the exact Ruby the Gemfile requires.

.github/workflows/ci.yml
- uses: ruby/setup-ruby@v1
  with:
    ruby-version: '3.3.0'   # match the Gemfile
- run: ruby --version

Or relax the requirement to a range

If you support several patch releases, loosen the pin so any compatible Ruby passes.

Gemfile
# Gemfile
ruby '~> 3.3'   # instead of ruby '3.3.0'

How to prevent it

  • Pin ruby-version in CI to match the Gemfile / .ruby-version.
  • Commit a .ruby-version file and have setup-ruby read it.
  • Use a range (~>) in the Gemfile if patch versions vary across environments.

Related guides

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