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.0Common 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
- Read the ruby directive in the Gemfile (or the .ruby-version file).
- Set setup-ruby to that version, or read .ruby-version.
- 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-versionHow 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
setup-ruby "The Ruby version X is not installed" in CIFix setup-ruby "The requested Ruby version is not available" in CI - the .ruby-version or workflow pins a Rub…
Bundler "Could not find compatible versions for gem X" in CIFix Bundler "Bundler could not find compatible versions for gem X" in CI - two dependencies require incompati…
Bundler "you must use Bundler 2.x" BUNDLED WITH mismatch in CIFix Bundler "you must use Bundler 2.x to run this bundle" in CI - the runner Bundler version differs from the…