Installing Ruby/Jekyll on macOS
I got a new laptop and as with any new laptop it is a mixture of joy and frustration. The joy is that you get to start from scratch and get rid of all the cruft that has built up on your machine. The downfall is all the little things that you forget about how you set up your machine before.
One of those snags I ran into today was reinstalling Jekyll (and by relation, Ruby). It's tricky because macOS comes preinstalled with Ruby 2.0.0 which makes you think you are all set but there are a ton of complications with it so it's better to just install your own copy of Ruby on your machine.
One of the issues was that when I tried to install Jekyll with my system Ruby, it provided the following error:
ERROR: While executing gem ... (Gem::FilePermissionError). You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
It wasn't any easier when I tried to install it using sudo. Thus, I googled and after some frustration searching I found the solution.
I'm documenting it here on my website so that I (and hopefully others) can find it easy in the future.
First you need to install Xcode.
Then, Install the Xcode Command Line Tools
xcode-select --install
Open Xcode or run the following code and agree to the terms
sudo xcodebuild -license
Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install))"
Install Ruby
brew install ruby
Install Jekyll
sudo gem install jekyll
Verify Jekyll
jekyll -v
VICTORY!