Run this command inside your terminal to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"MacOS comes with Ruby pre-installed but we're going to use Homebrew to get the latest version.
To install Ruby with Homebrew, run:
brew install rubyNow we need to add this installation to our path so that its used instead of the default MacOS one.
- Get the location of your Homebrew installed Ruby:
brew info ruby- Get the location of your gems:
gem environment gemdir- Use those to run the following command to prepend those locations to your path:
echo 'export PATH="{your-ruby-location}:{your-gem-location}:$PATH"' >> ~/.zshrcNote Depending on your shell, you might need to replace
~/.zshrcwith~/.bashrcor~/.bash_profile, etc.
Mine looked like this:
echo 'export PATH="/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.2.0/bin:$PATH"' >> ~/.zshrcRestart your terminal and run:
which rubyto verify that it points to the Homebrew installed Ruby.
Run the following to install Ruby on Rails:
gem install railsRestart your terminal and you should be good to go!