# Bundler: Your Ruby version is 3.1.2, but your Gemfile specified 3.3.0

**Code:** `Your Ruby version is X, but your Gemfile specified Y` · **Category:** Ruby / Rails · **Seen on:** Ruby

`.ruby-version`/the Gemfile `ruby` line requires a different Ruby than the one running.

## Meaning

Install and activate the right Ruby (`rbenv install 3.3.0 && rbenv local 3.3.0`, `rvm use`, `asdf`), or update the Gemfile and `.ruby-version` consistently. In Docker use the same base image tag. Run `ruby -v` and `which ruby` to confirm what's active.

## Common causes

- Wrong Ruby active (system Ruby)
- rbenv/rvm not initialised in the shell
- Gemfile `ruby` and `.ruby-version` disagree
- CI image uses another Ruby
- Version bumped but not installed

## Quick fix

1. `rbenv install $(cat .ruby-version) && rbenv local $(cat .ruby-version)`
2. Ensure `eval "$(rbenv init -)"` is in your shell rc
3. Align Gemfile/.ruby-version/Docker tag

## Detailed fix by platform

### Ruby

1. `ruby -v; which ruby; cat .ruby-version; grep '^ruby' Gemfile`

## How to diagnose

1. **Active** — ruby -v?
2. **Required** — Gemfile/.ruby-version?
3. **Manager** — rbenv/rvm initialised?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ruby/ruby-version-mismatch-gemfile)
