Skip to the workspace
Pebellslearn by building
Introduction and Setup  ›  Capstone Project

Version Managers

Managers 15 minA version manager selects among installed Ruby runtimes. Its project configuration determines which version a shell or tool should use.

ruby / Version Managers

Explore each scene at your own pace.

01 · The rule

The rule

Version Managers

A version manager selects among installed Ruby runtimes. Its project configuration determines which version a shell or tool should use.

Select the intended Ruby version for a project and verify the active executable.

Bean Cart's sales script runs on Ruby 3.3. Then a friend asks for help with their shop's older app, which only works on Ruby 3.1. Uninstalling and reinstalling Ruby every time you switch folders would be miserable. A version manager lets both live on one machine and picks the right one for you.

The rule

A version manager keeps many Rubies; the project folder picks one.

A version manager installs Ruby versions into your home directory and switches between them. The popular ones:

  • rbenv: small and focused. Pairs with ruby-build to install versions.
  • chruby: even smaller; pairs with ruby-install.
  • asdf (and its newer relative, mise): manage Ruby alongside Node, Python and other languages with one tool.
  • RVM: the oldest, with the most features, including its own named sets of gems. It changes more of your shell's behaviour than the others.

They all honour one small, shared convention: a file named .ruby-version in a project folder, containing just a version number.

rbenv install 3.3.5      # download and build Ruby 3.3.5
cd bean_cart
rbenv local 3.3.5        # writes .ruby-version containing 3.3.5
cat .ruby-version        # 3.3.5
ruby -v                  # ruby 3.3.5 ...

There is also a global default used when no .ruby-version file is found, set with rbenv global 3.3.5 (or the equivalent in your tool). The local file wins over the global default.

Commit .ruby-version to the project's repository. Then everyone who clones it, and many hosting services, will use the same Ruby you did.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.