Installing Ruby on macOS Big Sur
After switching to Mac I found myself needing to install Ruby and Jekyll to update my blog. However, the process of installing Ruby was, well, less than straightforward. I decided to publish this short guide incase it can be of use to anyone else in the same boat.
1. Install Ruby
To install packages on macOS I use Homebrew. After installing Homebrew, Ruby can be installed by simply using the following command
brew install ruby
2. Update your PATH
The next step is to add the following to end of your .zshrc
file
if [ -d "/opt/homebrew/Cellar/ruby/X.X.X/bin" ]; then
export PATH=/opt/homebrew/Cellar/ruby/X.X.X/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi
where X.X.X
is the version of Ruby that was installed in the previous step. Now (in a new terminal window), the command which ruby
should return the path specified above and the command ruby -v
should return the correct version.
Voila! Now you should be ready to use Ruby for whatever you wish.