You’ve decided it’s time to try Ruby. Maybe you’ve already tried Ruby, and now you’re ready to install Ruby on your computer.
If you’re using an operating system other than macOS Sierra 10.12 or macOS High Sierra 10.13, my friend Chris Oliver has an extensive collection of tutorials on how to install Ruby. His tutorials also include how to install Ruby on Rails. If you’re only interested in Ruby, you can stop after “Installing Ruby.”
Ruby version 2.0.0 comes installed on macOS Sierra. However, support for Ruby 2.0.0 ended on February 26, 2016. Also, as you begin to work on more Ruby projects, you’ll need to work with multiple Ruby versions. Luckily, several tools exist to help us install and manage multiple Ruby versions. The one I use and recommend is rbenv.
As a matter of fact, installing rbenv on macOS Sierra is easy thanks to Homebrew.
1. Install Homebrew
Homebrew is the “The missing package manager for macOS.”
To install Homebrew, open up your terminal and run:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. Install rbenv
After you’ve installed Homebrew, run the following command to install rbenv:
brew install rbenv
After rbenv is installed, run the following command to finish setting up rbenv:
3. Install Ruby
Finally, the fun part: Installing Ruby. I’d recommend installing version 2.4.2.
rbenv install 2.4.2
Once the install completes, tell your computer to use 2.4.2 by default:
rbenv global 2.4.2
4. Go Forth & Build
At this point, you should be ready to start using Ruby. If you run into any issues, I’m on Twitter several times a day. I also highly recommend a quick Google search. There are few things I’ve been unable to solve thanks to the internet.
I’m glad you’re interested in using Ruby. Learning Ruby & Ruby on Rails changed my career in ways unimaginable. I’m excited for you!Follow me on Twitter.