Skip to content
Latchkey

Bundler "Your Ruby version is 3.x, but your Gemfile specified 3.y" in CI

The Gemfile pins a Ruby version with a ruby directive, and the interpreter the runner uses is different. Bundler compares the two and refuses to proceed until they match.

What this error means

bundle install or bundle exec fails with "Your Ruby version is 3.2.2, but your Gemfile specified 3.3.0". The CI Ruby was provisioned to a different version than the Gemfile expects.

Bundler
Your Ruby version is 3.2.2, but your Gemfile specified 3.3.0

Common causes

The runner Ruby differs from the Gemfile ruby directive

setup-ruby (or the image) provisioned a different Ruby than the ruby "3.3.0" line in the Gemfile.

The Gemfile ruby was bumped without updating CI

The Gemfile now pins a new Ruby but the workflow still installs the old one.

How to fix it

Match the CI Ruby to the Gemfile

  1. Read the ruby directive in the Gemfile (or the .ruby-version file).
  2. Set setup-ruby to that version, or read .ruby-version.
  3. Re-run so the interpreter and the Gemfile agree.
.github/workflows/ci.yml
- uses: ruby/setup-ruby@v1
  with:
    ruby-version: '3.3.0'

Read .ruby-version automatically

Point setup-ruby at .ruby-version so the workflow tracks the pinned Ruby without a hardcoded number.

.github/workflows/ci.yml
- uses: ruby/setup-ruby@v1
  with:
    ruby-version: .ruby-version

How to prevent it

  • Keep the Gemfile ruby directive, .ruby-version, and CI in sync.
  • Have setup-ruby read .ruby-version so bumps propagate automatically.
  • Update the workflow in the same change that bumps the Ruby version.

Related guides

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