Ruby "Your Ruby version is X, but your Gemfile specified Y"
Your Gemfile declares a required Ruby version with a ruby directive. Bundler checks the interpreter actually running and stops when it differs, because installing against the wrong Ruby would produce a bundle that does not match what you declared.
What this error means
Any bundle command fails immediately with "Your Ruby version is 3.2.2, but your Gemfile specified 3.3.1." The CI runner is using a different Ruby than the Gemfile (or .ruby-version) requires.
Your Ruby version is 3.2.2, but your Gemfile specified 3.3.1Common causes
The CI Ruby differs from the Gemfile requirement
The runner has a default Ruby that does not match the ruby directive in your Gemfile (or the .ruby-version it reads).
setup-ruby installed a different version
The version in the setup step does not match what the Gemfile demands, so Bundler rejects the mismatch.
How to fix it
Install the Ruby the Gemfile requires
Provision the exact version in CI so it matches the ruby directive.
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.1' # match the Gemfile / .ruby-version
bundler-cache: trueOr align the requirement with reality
- Confirm which Ruby you actually want to support.
- If the Gemfile pin is wrong, update the ruby directive (and .ruby-version) to the supported version.
- Commit the change and re-run.
How to prevent it
- Drive the CI Ruby from .ruby-version with setup-ruby so it always matches the Gemfile.
- Keep the Gemfile ruby directive and .ruby-version in sync.
- Test against the exact Ruby version you deploy on.