Chapter 2: Installation and Setup

To use Ruby, we first have to install it on our computer. In this section, we’ll install the latest version of Ruby. If you’re on a Mac, it already comes with Ruby. However, it’s most likely an older version of Ruby.

There are many ways to install Ruby on your computer. The simplest way is to download Ruby is to use Homebrew, a package manager for macOS and Linux.

Homebrew is a very useful tool as it lets you easily download various software packages. Later, we’ll use Homebrew to install a database such as MySQL and other tools.

Using HomeBrew

First, install Homebrew by copy + pasting the following script into your Terminal window.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Check out the website to understand what the above script does.

Once it finishes, test if it was successfully installed by running the following command:

> brew --version
Homebrew 4.0.10

If it prints the version, it means Homebrew was successfully installed. Woohoo!

The next step is to install Ruby. Run the following command in the terminal:

brew install ruby

It takes a while, but once it’s installed, you can run the following command to see if everything went OK.

$ ruby --version

If it prints the Ruby version you installed, you’re good to go.

Next: Your First Ruby Program