How to Install Ruby 2.6.x on macOS Ventura and Monterey

Published by Moncef Belyamani on

Ruby 2.6.x is no longer supported on any Mac that has version 14 or higher of Apple’s command line tools (CLT), which would be the case on macOS Ventura (13.x) and the latest version of Monterey (12.6.x). Assuming you have Homebrew installed, you can check which version of the CLT you have by running brew config, and then look towards the bottom for the lines that start with CLT: and/or Xcode:

Ruby 2.6 reached end of life in March 2022, so it should not be used in production for security reasons. A lot of people get stuck because they think they have to use the version of Ruby that’s specified in the project’s .ruby-version and/or Gemfile. Instead, it’s recommended to update the project to a newer version. For more details, read my guide that explains how and why to upgrade the Ruby version in your project.

Now that you know the recommended approach, let’s go over three solutions in case you have a special need to use Ruby 2.6 before you update to 2.7.7 or 3.1.3:

  • Install Ruby 2.6.10 with Ruby on Mac Ultimate
  • Install Ruby 2.6.10 with Homebrew
  • Downgrade to version 13.4 of the command line tools

Install Ruby 2.6.10 with Ruby on Mac Ultimate

With Ruby on Mac Ultimate, installing Ruby 2.6.10 on Ventura or Monterey is as easy as running this command (after installing Ruby on Mac):

rom install ruby 2.6.10

You don’t have to do anything else to configure it, and you don’t have to mess with your PATH or shell file to be able to switch to other Ruby versions.

Install Ruby 2.6.10 with Homebrew

  1. Install Homebrew if you haven’t already
  2. Install Ruby 2.6.10: brew install ruby@2.6
  3. Follow the instructions for setting your PATH. For example, Homebrew will say something like this:
By default, binaries installed by gem will be placed into:

You may want to add this to your PATH.

If you need to have ruby first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc

The reason Homebrew is able to install 2.6.10 is because this is a pre-built version of Ruby that was compiled with version 13.3 of the command line tools. However, note that it’s not officially supported.

Unless you know what you’re doing, in order to use the Homebrew Ruby, you’ll need to disable any other version manager you might have used before (such as asdf, chruby, frum, rbenv, or rvm). And you’ll only be able to use 2.6.10 with this setup. You won’t be able to switch to other versions that you might have installed with another version manager, unless you make changes to your shell file to disable the Homebrew Ruby and turn your version manager setup back on. You’ll have to keep doing this each time you want to switch between 2.6.10 and other versions.

This is meant as a temporary solution so that you can run your project with 2.6.10 and then update it to 2.7.7. Also, note that either way, you’ll need to update your project to at least 2.6.10. There’s absolutely no reason to use any other version of Ruby 2.6.x. For security reasons, it’s recommended to make sure your apps are running the latest version in a series. For 2.6, it’s 2.6.10, for 2.7, it’s 2.7.7, then 3.0.5, 3.1.3, and 3.2.0.

Downgrade to version 13.4 of the command line tools

This is not possible on macOS Ventura (13.0), so don’t waste your time trying. It will probably take you less time to update your project to 2.7.7 than it would to downgrade from Ventura to Monterey.

If you’re on macOS Monterey, follow the steps below to download and install version 13.4 of the command line tools. Note that this is not guaranteed to work, depending on which version of Monterey you’re running. I had success with macOS 12.1, but some issues with 12.6.

Note that it should never be necessary to download the huge 7GB Xcode app unless you’re building macOS and iOS apps. In other words, if you’re never going to use the Xcode app itself, all you need are the standalone Command Line Tools.

  1. Download “Command Line Tools for Xcode 13.4”.
  2. Install them, but keep the DMG when it asks you if you want to Trash it, just in case you need to install them again.
  3. Check that Homebrew is using the correct CLT with brew config. You should see CLT: If not, try reinstalling them.
  4. Run brew doctor to make sure everything is fine. If not, follow Homebrew’s instructions for fixing issues.
  5. Reinstall all Ruby-related tools with Homebrew:
    brew reinstall automake bison gdbm libffi libyaml openssl@1.1 openssl@3 readline
  6. Install Ruby 2.6.10 with your favorite Ruby version manager. If you haven’t yet installed a version manager, you can either buy Ruby on Mac, which will set everything up for you in 15 minutes, or spend an hour following my step-by-step guide for installing Ruby on a Mac.