Rails is not currently installed on this system: how to fix this error


Did you just install Rails on your Mac, but got “Rails is not currently installed on this system” when you tried to use it?

Depending on how you installed Rails, the fix could be easy or complicated. Whatever you do, please don’t follow the instructions to simply type sudo gem install rails. Learn why you should never use sudo to install gems.

This error could also be due to how you installed Ruby. For example, with some version managers like rbenv, your system might not immediately recognize gems after installing them. Unlike other managers, chruby doesn’t have this problem, which is why it’s the Ruby version manager I recommend.

If you installed Ruby with Homebrew instead of a version manager, the first 4 solutions below are not going to help. I recommend uninstalling it from Homebrew, and going directly to Install Rails with chruby and ruby-install.

Below are five ways to fix the error “Rails is not currently installed on this system”. If you just want to get your Ruby project working as quickly as possible, and don’t feel like spending an hour or more reading through this guide and trying the various solutions manually, then I recommend buying Ruby on Mac.

Quit and restart Terminal

When you make changes to your development environment, they might not take effect right away. This is one of the most common sources of confusion, and quitting and restarting Terminal will solve many problems. Just like turning it off and on again.

If that doesn’t work, try the next solution in this guide.

Make sure your shell startup file is properly configured

For your computer to know about a command, gem, or other executable program, it has to be told where to look for it. It wouldn’t be efficient for the computer to search the entire hard drive for the program. Instead, it looks in a specific list of locations, which are stored in an environment variable called PATH. You can view this list by running this command in your terminal:

echo $PATH

When you install new programs, such as Rails, they might get installed in a location that is not already included in the PATH. If you don’t add this new location to the PATH, the computer won’t know to look for it there, and so it thinks it doesn’t exist.

This is one of the main reasons why I created Ruby on Mac. It automatically sets everything up for you. If you prefer to do things manually, read my guide about PATH and how to add locations to it.

Similarly, if you installed Ruby with a version manager (such as chruby, rbenv, asdf, or rvm), it requires you to add one or more lines to your shell startup file, and it’s a common step that people miss. Ruby on Mac does this for you automatically.

The most common shell startup files on a Mac are ~/.zshrc (if you’re using zsh), and ~/.bash_profile (if you’re using bash). If you’re not sure, read my guide to find out which shell you’re using.

For example, if you’re using chruby, and you installed it with Homebrew, you would need to add these two lines to your shell startup file (Ruby on Mac does this for you):

source "$(brew --prefix)/opt/chruby/share/chruby/chruby.sh"
source "$(brew --prefix)/opt/chruby/share/chruby/auto.sh"

If you’re using a different version manager, read their installation instructions for the lines you need to add, and then quit and restart your terminal for the changes to take effect.

If this still doesn’t solve the “rails is not currently installed on this system” issue, try the next solution.

Install Rails again

Another common scenario where a gem might not be found is when switching between Ruby versions. If you installed Ruby with a version manager (such as chruby, rbenv, asdf, or rvm), you’ll need to install gems separately in each version of Ruby.

For example, if you first installed Rails while using Ruby 3.1.5, and then you installed and switched to Ruby 2.7.8, Rails might not be there automatically. Some version managers (such as asdf and rbenv), as well as Ruby on Mac, let you define a list of gems that will automatically get installed each time you install an additional Ruby version. If you’re not using that feature, then you’ll need to run gem install rails again in each version of Ruby that you install.

If that doesn’t work either, try the next solution in this guide.

Switch to the correct Ruby version

Depending on how you installed Ruby, and whether or not you configured it properly, you might not be using your desired Ruby version. Anytime you cd into a new directory, you should check that you’re using the intended Ruby version:

ruby -v

For example, if you were expecting 3.1.5, but you got 2.6.10 (or older), that’s most likely the version of Ruby that came preinstalled on your Mac, known as the system Ruby. You can check by running which ruby. It if says /usr/bin/ruby, that’s the system Ruby, and you don’t want that. Learn about the 5 reasons why you shouldn’t use the system Ruby.

One way to make sure you’re using a newer version of Ruby is to switch to it manually (assuming you already installed it). The command for doing that will depend on the version manager you’re using. With chruby, the version manager I recommend, it would be like this:

chruby 3.1.5

Then check the version again:

ruby -v

Another highly-recommended way to automatically switch between versions is to add a .ruby-version file in your Ruby project with the desired version number, such as 3.1.5. This is a standard that all version managers follow, but with asdf, it requires adding legacy_version_file = yes to your ~/.asdfrc.

Whenever you cd into a directory that has a .ruby-version file, the version manager will try to switch to that version. If that version doesn’t exist, then you might either get a helpful error message (like with chruby) or some version managers might fail silently and revert to the system Ruby, or some other unexpected behavior.

If this still doesn’t fix the “rails is not currently installed” issue, try the next solution.

Install Rails with chruby and ruby-install (most reliable)

Of all the possible ways to install Rails on a Mac, I recommend using a Ruby manager. This allows you to have multiple versions of Ruby installed at the same time, and makes it easy to switch between them. And of all the Ruby managers, I recommed chruby and ruby-install because they’re the most reliable and easiest to use.

Even if you don’t think you’ll need more than one Ruby version now, it’s worth your time to learn how to use a Ruby version manager because you’ll inevitably need one.

Over the past twelve 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.

You have two options for setting up a proper Ruby environment with chruby and ruby-install:

Have everything set up for you in 15 minutes or less with a single command

My paid script Ruby on Mac (released in February 2022) will automatically install Ruby with chruby, ruby-install, and all the other development tools you’ll need for Rails. Over 2200 happy customers have saved so much time and frustration.

When you buy Ruby on Mac today, you’ll be supporting an independent developer and his family, and if you need it for your job or business, you should be able to expense it.

See how much people love Ruby on Mac.

Spend an hour or more setting everything up manually

Follow my free step-by-step guide for installing Ruby on Mac with chruby and ruby-install. The guide works best when you’re starting with a clean Mac.