Ruby

audience developer
level all
topic Ruby
subtopic Installation

Install Ruby with Frum

Most developers should install a software version manager before installing Ruby. It will help you manage multiple versions of Ruby. Asdf is a good choice because it can manage versions of many languages, including Ruby and Node. Instructions for asdf are in the section, Install Asdf Version Manager. If you don't want to use asdf, or if you have problems with it, I recommend Frum, as it is the newest and fastest Ruby version manager.

If you are a casual user and won't be using Ruby frequently, you can use Homebrew to install Ruby. See the page, Install Ruby with Homebrew.

Frum is written in Rust, a good language for fast command line execution of system software. It is new (released in early 2021). Unlike asdf, chruby, or rbenv, it includes a built-in Ruby installer command so there's no extra program needed to install Ruby. The installer is fast and Frum requires no dependencies (it's an all-in-one Rust executable you can install with Homebrew). The Frum version manager is added to your shell to intercept any calls to Ruby. After you install Frum, you must modify your ~/.zshrc file so Frum runs in your local shell environment. Like the other version managers, it checks for a .ruby-version file in a project directory and, if there's no version specified for a project, it will default to a global Ruby version. There are no shims (unlike Asdf or Rbenv) and it doesn't override the cd command (unlike RVM). Though it is new, I recommend it because it's all-in-one and fast.

Here are instructions for installing Frum and Ruby.

Before you get started

You'll need a terminal application to install Ruby. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.

Mac system Ruby

MacOS comes with a "system Ruby" pre-installed. MacOS Sonoma includes Ruby 2.6.10 which is not the newest version. It's a bad idea to use the Mac system Ruby. See the article Do not use the MacOS system Ruby. You can see the system Ruby with which ruby and ruby -v.

Leave the system Ruby in place and install the Frum version manager and the newest Ruby version.

Install OpenSSL

Many Ruby gems (including Rails) require OpenSSL but it is not included in Ruby. By default, frum uses OpenSSL installed via Homebrew. Before you install frum, use Homebrew to install OpenSSL.

$ brew install openssl

Verify that OpenSSL is available by running brew list openssl:

$ brew list openssl
/opt/homebrew/Cellar/openssl@3/3.0.1/.bottle/etc/ (7 files)
/opt/homebrew/Cellar/openssl@3/3.0.1/bin/c_rehash
/opt/homebrew/Cellar/openssl@3/3.0.1/bin/openssl
/opt/homebrew/Cellar/openssl@3/3.0.1/include/openssl/ (135 files)
/opt/homebrew/Cellar/openssl@3/3.0.1/lib/libcrypto.3.dylib
/opt/homebrew/Cellar/openssl@3/3.0.1/lib/libssl.3.dylib
/opt/homebrew/Cellar/openssl@3/3.0.1/lib/engines-3/ (3 files)
/opt/homebrew/Cellar/openssl@3/3.0.1/lib/ossl-modules/legacy.dylib
/opt/homebrew/Cellar/openssl@3/3.0.1/lib/pkgconfig/ (3 files)
/opt/homebrew/Cellar/openssl@3/3.0.1/lib/ (4 other files)
/opt/homebrew/Cellar/openssl@3/3.0.1/share/doc/ (784 files)
/opt/homebrew/Cellar/openssl@3/3.0.1/share/man/ (5472 files)

There might be another step required to use OpenSSL with Ruby. I've opened an issue can't find OpenSSL and I'll update this guide when I learn more.

Install Frum

Use Homebrew to install the Frum Ruby version manager.

$ brew install frum

You'll see beer mug emojis as Homebrew installs the utility.

Verify that Frum is available by running brew list frum:

$ brew list frum
/opt/homebrew/Cellar/frum/0.1.2/.crates.toml
/opt/homebrew/Cellar/frum/0.1.2/.crates2.json
/opt/homebrew/Cellar/frum/0.1.2/bin/frum
/opt/homebrew/Cellar/frum/0.1.2/etc/bash_completion.d/frum
/opt/homebrew/Cellar/frum/0.1.2/share/fish/vendor_completions.d/frum.fish
/opt/homebrew/Cellar/frum/0.1.2/share/zsh/site-functions/_frum

We must add Frum to the system environment before we can use it to manage Ruby versions.

Add Frum to the .zshrc file

Edit the ~/.zshrc file in your text editor. If you haven’t installed a text editor, use the macOS TextEdit application. Here’s a shortcut to open the file in TextEdit from the Terminal:

$ open -e ~/.zshrc

Add a shell configuration command for Frum:

### ~/.zshrc~
# enable frum
eval "$(frum init)"

The first two lines (with the hash characters) are comments. The third line makes the Frum program available in the shell.

Save the file.

🚩 Close and reopen the Terminal window for the changes to the ~/.zshrc file to be recognized.

After closing and reopening the Terminal window, use frum -h to check that Frum was installed successfully.

Next we'll install Ruby.

Install Ruby

Frum has its own Ruby installation command. No extra software is needed to install Frum.

Use the command frum install -l to list all available Ruby versions.

$ frum install -l

You can check online for the current recommended version of Ruby.

When this was written, Ruby 3.4 was the newest version (3.4.1 was released on Dec 25, 2024).

Use frum install 3.4.1 to install the newest Ruby version.

$ frum install 3.4.1

You’ll see diagnostic messages and progress updates. Installation is faster with Frum than other installers; it will take a few minutes.

🚩 After installation, close and re-open the terminal window.

Verify that the newest version of Ruby is installed with ruby -v.

When this was written, Ruby 3.4.1 was the newest version.

If you see Ruby version 2.6.10, it is the system Ruby and you likely forgot to close and re-open the terminal window.

The Tips: Uninstalling Ruby section explains where Ruby versions are installed and how to remove them. To remove a Ruby version with Frum, use frum uninstall 3.4.1.

Using Frum

Set a default Ruby version with frum global 3.4.1.

See which Ruby versions are installed and which is the current version with frum versions.

$ frum global 3.4.1
$ frum versions
* 3.4.1

If you have more than one Ruby version installed and you want to switch temporarily from the default Ruby version, use (for example) frum local 2.7.3.

You can add a .ruby-version file to any project directory to force Frum to switch versions when you enter a project folder. The .ruby-version file simply contains a version number, for example 3.4.1.

For your next step, optimize the Ruby development environment by updating gems. See the Update Gems section.

If you want to install Rails (the web application framework), see Install Ruby on Rails.