Is Ruby installed on my Mac?
Ruby comes pre-installed on macOS Catalina and Big Sur (see below why you may not want to use the default Ruby).
To check if Ruby is installed, enter in your terminal application:
$ ruby -v
(Don't type the $
character.)
If Ruby is not installed, you'll see:
zsh: command not found: ruby
The which
command will confirm that Ruby is missing:
$ which ruby
ruby not found
You can use the which
command with flag -a
to see if more than one Ruby executable is installed:
$ which -a ruby
/Users/daniel/.asdf/shims/ruby
/usr/bin/ruby
If Ruby is installed, the ruby -v
command will show a response like:
$ ruby -v
ruby 2.6.3p62
MacOS comes with a "system Ruby" pre-installed. Use the which
command to see if you are using the system Ruby:
$ which ruby
/usr/bin/ruby
If you see /usr/bin/ruby
, it is the pre-installed macOS system Ruby. It's fine to use the system Ruby for running sysadmin scripts, as long as you don't alter the system Ruby by attempting to update it or add gems. But experienced developers don't use the system Ruby for developing projects in Ruby. See the article, Do not use the MacOS system Ruby. You can Install Ruby with Homebrew. Or 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.
For a guide that compares version managers and shows the best way to install Ruby, see Install Ruby on a Mac. If you're going to build web applications with Rails, see Install Ruby on Rails on a Mac.
Top comments (0)