Install Ruby on macOS

Contents
Homebrew setup
Install Ruby with brew
Check ruby -v and which ruby
Adjust the PATH

Homebrew setup

macOS ships with a system Ruby that is meant for the system itself, so developers usually install a separate Ruby with Homebrew.

Homebrew is a popular package manager for macOS, mentioned here as plain text. If it is already on your machine, update it first so the Ruby formula is fresh.

Install Ruby with brew

One brew command installs a current Ruby beside the system one:

Install Ruby

brew install ruby

Wait until the install finishes and read the final hints printed by brew. Those hints explain how your shell finds the new Ruby.

Check ruby -v and which ruby

Open a fresh terminal and confirm both the version and the location of the Ruby that runs by default:

Show the installed Ruby version

ruby -v

ruby 3.3.0 (2023-12-25 revision 7b0c32346b) [arm64-darwin22]

Show which Ruby runs by default

which ruby

ruby found through Homebrew

If the location still points to the system Ruby, continue to the PATH section below and then open a fresh terminal again.

Adjust the PATH

Brew Ruby is keg-only, which means it stays out of the way until you ask for it. That design protects the system Ruby from accidental changes.

To use brew Ruby by default, adjust the PATH so the brew folder comes first, following the hints printed after install. Restart the terminal after the change and check ruby -v once more.

Next: Install Ruby on FreeBSD

Article author: Arthur Isaev

Related articles
Ruby
Ruby course: zero to hero in 50 lessons
What is Ruby and where it runs
Install Ruby and check the version
irb: the interactive shell
Your first Ruby script
Variables
Numbers
Strings
Symbols
Truthiness: only false and nil
Conditions
Loops
Arrays
Hashes
Ranges
Methods
Blocks, procs, lambdas
String tools
Files and IO
Exceptions
Modules and mixins
Classes and objects
Inheritance
Enumerables
Duck typing and core idioms
Gems and Bundler
Testing with Minitest
Debugging
Encodings
Time and date
JSON and YAML
HTTP clients
Sockets
REST APIs
puts, print and p
Metaprogramming
Enumerators
Pattern matching
Arguments: splats and kwargs
Rake tasks
Environment and CLI
Logging
CSV
ERB templates
WEBrick server
Rails in one lesson
Capstone: todo CLI
Capstone: JSON API
Performance
Modern Ruby tour
Hero roadmap: the whole course on one page
Install Ruby on Windows 11
Install Ruby on Ubuntu
Install Ruby on Rocky Linux
Install Ruby on macOS
Install Ruby on FreeBSD
Ruby in Docker
Threads and fibers

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: