Ruby

audience developer
level all
topic Ruby
subtopic Installation

Install Ruby 3.4

Install Ruby Mac (M1, M2, M3 or Intel). How to install Ruby on macOS. Using Homebrew or version managers. Covers the Ruby latest version, PATH, and gems. Instructions, with troubleshooting tips.

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.

You'll need Xcode Command Line Tools before you install Ruby. You can Install Xcode Command Line Tools with Homebrew.

It's optional, but if you're setting up a local development environment you'll need to Install Git and Configure Git with the Git Credential Manager so you can save your work as you go with version control.

Steps

Before you install Ruby, prepare your development environment:

You can install Ruby directly with Homebrew:

Or install Ruby with a software version manager:

Then finish preparing your development environment:

Before you get started, take a moment to tell me What do you want to do next? so I know what else you need.

Automated and assisted installation

If you need just one version of Ruby, use Homebrew (it's easy and free). Or develop your skills and use a software version manager to install Ruby. But if things go wrong, or you want assistance, I recommend Ruby on Mac, a $49 installation script from Moncef Belyamani that installs Ruby using chruby. A $149 premium version gives you a choice of version managers asdf, chruby, frum, rbenv or rvm. Moncef Belyamani is a good guy and provides support if you have Ruby installation problems. He's also written an excellent guide, titled The Fastest and Easiest Way to Install Ruby on a Mac in 2024.

Homebrew or a Ruby version manager?

Before you install Ruby, decide if you should use a software version manager or just install Ruby with Homebrew.

First, understand the difference between Homebrew and software version managers. Homebrew is a package manager that adds Ruby, other languages, and software packages to the Mac. It can install one (and only one!) version of Ruby (usually the latest version). You can also use Homebrew to install software version managers that install and switch between multiple versions of a language such as Ruby. Here's how to choose.

Here's a comparison of Ruby version managers (plus Homebrew and Docker):

Homebrew for one Ruby version

Install with Homebrew if you’re building only one project with Ruby (for example, if you are a student learning Ruby). If you’re a solo developer and you need to juggle multiple projects that can't be updated all at once, use asdf or frum. Choose asdf if you're using multiple languages such as Ruby, Node, and Python; otherwise frum is the newest and fastest version manager purely for Ruby. Finally, use Docker (or Nix) if you’re on a team with a complex project environment (for example, Ruby, Node, Redis, and PostgreSQL all in one project). Here are details.

asdf is a universal version manager

Asdf is a good choice because it is a universal version manager that installs and manages Ruby, JavaScript, Python, Elixir, and several other languages.

Frum for just Rubies

Frum is simple and fast, working only with Ruby, with a built-in installer.

Chruby works only for Ruby but (unlike Frum) requires installation of a separate installer utility.

Rbenv and rvm are also popular as Ruby version managers. Sam Stephenson's rbenv has a more complex implementation than frum or chruby (it installs extra “shim” files). RVM was once the most popular of Ruby version managers but its additional features (gemsets) are no longer needed and add unnecessary complexity.

Docker is a containerization tool that some developers use for version management. The primary use case for Docker is to create a reproducible virtual server that contains a configured version of any software dependency needed to run an application (language, databases, message queues). As such, it is ideal for creating a "frozen" version of a development environment for deployment to a server. You can also develop locally within a container but it will run slower, require more memory, and adds configuration complexity compared to a simple version manager. To keep things simple, don't use Docker for local development unless your application is disturbingly complex.

Don't use the system Ruby

Finally, you should know that macOS comes with a system Ruby pre-installed. MacOS Sonoma includes Ruby 2.6.10 which is not the newest version. If you use the system Ruby you'll need root access (sudo) to install gems (introducing a security risk). And you'll end up with a cluster of (sometimes incompatible) gems that can't be easily removed to restore your system to a clean state. Please Do not use the MacOS system Ruby (see the article).

Recommendation

If you don't need a version manager, install Ruby using the Homebrew package manager. Use this approach if you are only building a casual project or if you are just trying out Ruby to learn the language. You can easily remove Ruby after installing with Homebrew (and re-install a newer version when you need it). Don't install Ruby with Homebrew if you need to switch among Ruby versions (use asdf or frum in this case).

You'll find instructions here for installing Ruby using asdf, frum, or Homebrew.

In the next sections, you'll check your macOS version, install Xcode Command Line Tools, install Homebrew so you can either directly install Ruby or install a software version manager, and finally install Ruby with either asdf, frum, or Homebrew.

Continue to the next section to check your computer before installing Ruby.

What's next

My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.