Installing Ruby on macOS

suggest change

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 Homebrew’s bin directory to the start of your $PATH. On Intel Macs that is often /usr/local/bin; on Apple Silicon it is often /opt/homebrew/bin:

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

Adding that line to ~/.bash_profile (or ~/.zprofile if you use zsh) takes effect in a new login shell:

$ 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents