Ruby Language Installing Ruby macOS


So the good news is that Apple kindly includes a Ruby interpreter. Unfortunately, it tends not to be a recent version:

$ /usr/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

If you have Homebrew installed, you can get the latest Ruby with:

$ brew install ruby

$ /usr/local/bin/ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

(It's likely you'll see a more recent version if you try this.)

In order to pick up the brewed version without using the full path, you'll want to add /usr/local/bin to the start of your $PATH environment variable:

export PATH=/usr/local/bin:$PATH

Adding that line to ~/.bash_profile ensures that you will get this version after you restart your system:

$ type ruby
ruby is /usr/local/bin/ruby

Homebrew will install gem for installing Gems. It's also possible to build from the source if you need that. Homebrew also includes that option:

$ brew install ruby --build-from-source