Is Ruby Installed On A Mac? How To Check On macOS Catalina and Big Sur

Written by railsapps | Published 2021/02/25
Tech Story Tags: ruby | macos | ruby-on-rails | ruby-on-rails-development | learn-to-code-ruby | programming | mac-hacks | mac-troubleshooting

TLDR Is Ruby installed on a Mac? How To Check On macOS Catalina and Big Sur? How to check if Ruby is installed. MacOS comes with a "system Ruby" pre-installed. You may not want to use the MacOS system Ruby because it is an older version of Ruby. You could also 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.via the TL;DR App

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.
You may not want to use the MacOS system Ruby because it is an older version of Ruby. Instead, you can Install Ruby with Homebrew. You could also 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.
Also published on Dev.to.

Written by railsapps | Author of the book, "Learn Ruby on Rails" and founder of the RailsApps open source project.
Published by HackerNoon on 2021/02/25