To find out what version of Ruby is installed on macOS,enter the following into your terminal application:
$ ruby -v
Don’t type the
＄ character – the
＄ character is just a cue that you should enter a shell command.
If Ruby is installed, the
ruby -v command will show a response like:
$ ruby -v ruby 3.0.0p0
ruby -v command will show you the Ruby version number.
If Ruby is not installed, you’ll see:
zsh: command not found: ruby
which command can confirm that Ruby is missing:
$ which ruby ruby not found
If Ruby is installed, the
which command may show the Ruby version number in the file path:
You may want to know more than the Ruby version number. You may want to know how Ruby is installed and where Ruby is installed. The
which command will show you.
You can use the
which command with the
-a flag to see if more than one Ruby executable is installed and where they are installed:
$ which -a ruby /Users/daniel/.asdf/shims/ruby /usr/bin/ruby
MacOS comes with a “system Ruby” pre-installed. If you see
/usr/bin/ruby when you use the
which command, it is the pre-installed macOS system Ruby. It’s a bad idea to use the Mac system, Ruby, for developing Ruby applications (it’s fine to use it for running utility scripts).
See the article Do not use the MacOS system Ruby.
That’s why developers use a version manager such as asdf, chruby, rbenv, or rvm. A version manager can also help if you’re juggling multiple projects that can’t be updated all at once.
Homebrew is a package manager that adds languages or software packages to the Mac. It can install one (and only one!) version of Ruby (usually the latest version). When you use the
which command, you’ll know you are using a Homebrew-installed version of Ruby if you see,
/usr/local/... (on Mac Intel) or
/opt/homebrew/... (for Apple Silicon).
The version of Ruby installed by Homebrew is primarily intended for use by other Homebrew packages. As such, it can be updated to a newer version without warning when Homebrew updates the dependencies of other packages. If you are a casual Ruby user (for example, learning the language or working on a single personal project), it is convenient to install the latest Ruby with Homebrew. However, if your project depends on a specific version of Ruby, or if you are developing multiple Ruby projects that cannot be updated all at once, you should not rely on the single version of Ruby installed by Homebrew. Instead, install a software version manager such as asdf, chruby, rbenv, or rvm.
For a guide that compares version managers and shows the best way to install Ruby, see Install Ruby on a Mac.
After you’ve found the Ruby version and learned how it was installed, you may want to Change Ruby version on Mac.
For more on this topic, see the expanded article Check Ruby version Mac.
View all Courses