Fix 'Rails is not currently installed on this system' on macOS
By Flavio Copes
How to fix the 'Rails is not currently installed on this system' error on macOS by installing rvm, then using it to install Ruby and Rails and sourcing rvm.
The fix for the Rails is not currently installed on this system error on macOS is to stop using the system Ruby, install a Ruby version manager like rvm, and let it install Ruby and Rails for you.
That’s the short version. Here’s the full story.
I tried to install Rails but I kept getting that error every time I typed rails. macOS ships with its own Ruby, but it’s there for the operating system, not for you. It’s old, and installing gems into it is a fight against permissions you don’t want to have. The rails message you see comes from a macOS stub, not from a real Rails install.
The clean way out is a separate Ruby, managed by a version manager, living in your home folder. No sudo, no touching system files.
I couldn’t figure it out, until I did the following steps.
Install rvm
First, install gpg2, which rvm uses to verify its installer:
brew install gpg2
Then import the keys the rvm installer is signed with:
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Then I ran the installer:
curl -sSL https://get.rvm.io | bash -s stable --rails
This installs rvm itself, plus the latest stable version of Ruby, plus Rails. The --rails flag at the end is what saves you from installing Rails as a separate step.
Everything lands under ~/.rvm, inside your home folder. That’s why no sudo is needed.
Load rvm in your shell
The install alone isn’t enough. Your current shell doesn’t know about rvm yet, so rails still fails. This is the step that trips people up.
On Bash or Zsh, I ran:
source /Users/flavio/.rvm/scripts/rvm
and the rails command worked fine. New terminal windows load rvm automatically, because the installer adds this line to your shell profile.
You can confirm the right Ruby is active with which ruby. It should print a path under ~/.rvm, not /usr/bin/ruby. If you still see /usr/bin/ruby, the shell hasn’t loaded rvm, and you’ll get the same Rails error again.
Fish shell
On Fish, instead of the above command I had to run:
curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
and
echo "rvm default" >> ~/.config/fish/config.fish
This downloads a Fish function that wraps rvm, then makes Fish activate the default Ruby on every new session. After restarting the terminal, rails worked there too.
Want me to talk about your product? You can sponsor this site.
Related posts about mac: