How to Install Rails on Mac (M1 and Intel), the Easy Way

Updated

With this updated guide for 2023, you’ll be able to install Rails 7 on your Mac in minutes.

Every day, many people get stuck trying to install Rails on macOS due to outdated, incomplete, and confusing instructions. Especially on Apple Silicon Macs. Today, you’re about to save a lot of time and frustration.

Here are the two best ways to install Rails on a Mac:

Install Rails on Mac with an automated script that does everything for you

To install Rails on a Mac, you first need a proper Ruby development environment. Even though macOS come preinstalled with Ruby, it’s not recommended to use the version that came with your Mac, known as the system Ruby. To learn more, read why you shouldn’t use the system Ruby.

Setting up a proper Ruby development environment on a Mac involves several steps, which many people fumble when trying to follow long tutorials or videos. You might get confused about which shell you’re using, or why you’re getting a “Rails is not currently installed on this system” error even after successfully installing Rails.

To eliminate any chance of human error, I built Ruby on Mac, a reliable script that automates the whole process with a single command, and with a perfect result every time. It also automatically installs Rails and all the other development tools you’ll need.

It doesn’t just have a one-time use. You can run it over and over to keep your dev tools up to date and secure. And the next time you get a new Mac, it will save you a whole day because it can also automatically install all your Mac apps, fonts, macOS preferences, and GitHub repos, in addition to a complete development environment. You get all of these time savings now and in the future for a one-time cost.

If you’re trying to set up Rails on a work computer, you should be able to expense the one-time cost of Ruby on Mac.

Read how much people love Ruby on Mac.

Install Rails on Mac manually with a Ruby version manager

While there are various ways to install and use Ruby on a Mac, there’s only one method I recommend: by installing a separate version of Ruby using a version manager. To learn more, read my definitive guide to installing Ruby gems on a Mac.

Over the past ten years, I’ve helped hundreds of thousands of people set up Ruby on their Mac. From clean Macs to the most obscure issues, I’ve seen and fixed it all. And the most reliable solution is to use a version manager, specifically chruby.

If you haven’t yet tried to install Ruby or other development tools on your Mac, you should be able to get up and running with the basics by following my step-by-step guide for installing Ruby on a Mac.

If you’ve already tried to set things up and you’re running into issues you can’t figure out, you can still try my step-by-step guide, but Ruby on Mac will get you unstuck much faster.

Install Rails

Once you have a proper Ruby development environment, you should be able to install the Rails gem and create a new Rails site.

First, make sure you’re using a newer version of Ruby, and not the system Ruby (the one that came preinstalled on your Mac). If you’re creating a brand new Rails site, I recommend either 3.1.4 or 3.2.2.

Run this command to check which version of Ruby is currently active:

which ruby

If it says /usr/bin/ruby, that’s the system Ruby. You’ll want to switch to one of the versions you installed with a version manager. If you’re a Ruby on Mac customer, you should already have 3.1.4 installed, and you can switch to it like this:

chruby 3.1.4

If it says that 3.1.4 is unknown, then install it. If you’re a Ruby on Mac customer, read the Post-Installation Guides to learn how to install additional Ruby versions. If you’re not a Ruby on Mac customer, look up the instructions for the version manager you’re using.

Then install Bundler and Rails:

gem install bundler rails

Create a new Rails app

cd into the folder where you keep all your projects. For example:

cd ~/projects

Create a directory for your app and cd into it:

mkdir my-rails-app && cd my-rails-app

Once again, switch to the desired Ruby version. Example:

chruby 3.1.4

You can double check that you are indeed using 3.1.4 with this command:

ruby -v

Generate a new Rails app with one of these commands below, depending on which database you want to use. The first command will use the default SQLite DB, and the second will use Postgres.

To use SQLite:

rails new .

To use Postgres:

rails new . -d postgresql

If you see a message at the end that says “Could not find gem ‘redis (~> 4.0)’ in locally installed gems,” run bundle install as the message suggests. This should complete the Rails app creation.

Next, try creating a database:

bin/rails db:create

If you’re using Postgres, the command above assumes you already have Postgres installed with Homebrew or via the Postgres Mac app, and that the Postgres server is running. If you’re a Ruby on Mac customer, Postgres was already installed for you via Homebrew, and you can start it like this:

brew services start postgresql@14

Then confirm that it’s running (it should say started in green):

brew services list

If it says error, read my Postgres troubleshooting guide to fix it.

Run the Rails server:

bin/rails s

and visit your Rails app at http://localhost:3000.

Further reading

Once you have your Rails app up and running, I recommend reading about the first gem you should add to your Rails app.