This post describes how to install homebrew, and use it to fix your Ruby install.

Enable Ruby

First up, let's enable Ruby. We are installing Ruby first as other items needed for development and installation require it.

Step 1: Install X-code, and check to make sure that its the latest

To install x-Code, head over to the app store then click: "categories" > "development". It is typically near the top of the free downloads. Click the download button, then go grab a snack.... it clocks in at about 8GB so it may take awhile to download and install.

If you already have it installed, make sure its up to date.

Step 2: Accept the license agreements

In order to use the build tools, the licenses must be accepted. Run the below commands in your terminal ("Utilities" > "Terminal"). Be sure to read and accept the agreements.

xcode-select --install

Step 3: Check if Ruby is installed, then update the files

To check what version of Ruby you have, you will need to run the below command in the terminal:

ruby -v

To update your ruby installation and gems to the latest version, run the below commands. Please note that multiple versions of Ruby are beyond the scope of this blog. If you want to run multiple versions, check out a project like RVM (Stack Overflow post: fixing Ruby).

Install homebrew

Homebrew is basically a package manager for the Mac, and in this being used to fix the default Ruby version that comes with the Mac. It will also be used further into the tutorial to install other development items.

Go to the homebrew site (brew.sh) and check out the latest download code and run in in the terminal. It should look something like this:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Homebrew website

Once the install has completed, its best to run the below commands to make sure your installation is okay and has the latest files.

brew doctor
brew update

Please note that Homebrew commands are easiest for fixing Ruby, however, as mentioned above, some prefer Ruby Version Manager (RVM) to switch Ruby versions.

Updating Homebrew packages

To update packages, you will need to run an update, and upgrade like below:

Brew update
brew upgrade

Update Ruby and installed gems.

brew install ruby
sudo gem update --system
sudo gem update

Resources