If you’re trying to install Rails on macOS and you keep encountering the error “Rails is not currently installed on this system,” don’t worry. There’s a solution to get Rails up and running smoothly. Follow these steps:

Step 1: Install rvm

First, you need to install rvm. rvm is a popular Ruby version manager that allows you to easily switch between different versions of Ruby. Open your terminal and run the following command to install gpg2:

brew install gpg2

Once gpg2 is installed, proceed to import the required GPG keys by executing the following command:

gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Step 2: Install Ruby and Rails

After importing the GPG keys, you’re ready to install the latest stable version of Ruby and Rails. Run the following command in your terminal:

curl -sSL https://get.rvm.io | bash -s stable --rails

This command will automatically install the latest stable version of Ruby and Rails for you.

Step 3: Set up the RVM script

Now that you have Ruby and Rails installed, you need to set up the RVM script in your shell. Depending on the shell you’re using, follow the appropriate instructions:

For Bash / Zsh

If you’re using Bash or Zsh, run the following command:

source /Users/flavio/.rvm/scripts/rvm

Make sure to replace /Users/flavio/.rvm/scripts/rvm with the correct path to the RVM script on your system.

For Fish

If you’re using Fish as your shell, you need to run different commands. Execute the following commands one by one:

curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
echo "rvm default" >> ~/.config/fish/config.fish

These commands will set up the RVM script for Fish.

Conclusion

After completing these steps, you should be able to use the rails command without encountering the error “Rails is not currently installed on this system.” Enjoy building amazing Ruby on Rails applications!