Purpose: verify the active Ruby matches what a Rails project requires before installing gems or running generators. Mismatched Ruby is a common cause of confusing bundle install and bin/rails failures.
Used by: any skill that touches a Rails project's gems, runs Rails generators, or runs make test / make lint. Reference this file from <RAILS_DIR> (the located Rails app directory) — all paths below are relative to it.
Check, in order:
<RAILS_DIR>/.ruby-version(one line, e.g.3.3.4)<RAILS_DIR>/Gemfilefor aruby "X.Y.Z"line<RAILS_DIR>/.tool-versionsfor aruby X.Y.Zline (asdf)
Save the required version as <REQUIRED_RUBY>. If none of those files specify a Ruby version, skip the rest — there is no version to enforce.
ruby -vIf the major.minor.patch matches <REQUIRED_RUBY> → done. Continue with the calling skill.
If it does not match → continue to Step C.
Your active Ruby is
<active>but the project requires<REQUIRED_RUBY>. Which Ruby version manager do you use? (rbenv / asdf / rvm / chruby / other)
First check whether the version is installed; if not, install it. Then activate it.
| Manager | Check installed | Install if missing | Activate |
|---|---|---|---|
| rbenv | rbenv versions | grep -q <REQUIRED_RUBY> |
rbenv install <REQUIRED_RUBY> |
rbenv local <REQUIRED_RUBY> (run inside <RAILS_DIR>) |
| asdf | asdf list ruby | grep -q <REQUIRED_RUBY> |
asdf install ruby <REQUIRED_RUBY> |
asdf local ruby <REQUIRED_RUBY> (run inside <RAILS_DIR>) |
| rvm | rvm list strings | grep -q <REQUIRED_RUBY> |
rvm install <REQUIRED_RUBY> |
rvm use <REQUIRED_RUBY> |
| chruby | chruby | grep -q <REQUIRED_RUBY> |
install via ruby-install <REQUIRED_RUBY> (tell user if ruby-install is missing) |
chruby <REQUIRED_RUBY> |
| other / unsure | — | — | Stop. Ask the user to switch manually, then confirm before continuing. |
Notes:
rbenv install/asdf install rubymay take several minutes (compiling Ruby). Tell the user before running.- After activating, re-run
ruby -vto confirm. If still mismatched (shell hasn't picked up the new version), stop and ask the user to open a new shell orsourcetheir rc file. - Do not run
sudofor any of these — version managers are per-user.
bundle -vIf bundle is missing → gem install bundler. Then continue with the calling skill.
| Problem | Fix |
|---|---|
ruby -v still old after rbenv local |
Open a new shell, or run eval "$(rbenv init -)" in current shell |
asdf install ruby <ver> fails with build errors |
User missing build deps (openssl, readline). Direct them to asdf-ruby README. |
| Multiple version managers installed (e.g. rbenv + asdf) | Ask which one is authoritative; mixing causes silent shadowing |
.ruby-version and Gemfile disagree |
.ruby-version wins for the version manager; Gemfile ruby line is enforced by Bundler. Ask user to reconcile. |