Home > Mac

Check, Update & Install ruby on rails and ruby on Mac

In this article you will learn, how you can check if your MacBook Air or any other Mac device has already have Ruby pre-installed. You have to use the linux terminal of your MacBook to do that.

And after checking the Ruby language version we will install Ruby on Rails and the more advanced developer version of Ruby language on your MacBook if needed.

Updating and checking Ruby language is pretty easy and can be done with 2-3 commands. So, for the starters the difference between Ruby and Ruby on Rails is; the former is a programming language and the latter is a Web framework. So, the Ruby on Rails is a Web framework which runs on the Ruby programming language.

Also check: Install Polyglot on Mac

So, let’s begin now:

Check if Ruby is installed on Mac or not?

Open the terminal app on your MacBook or iMac and enter the following command:

ruby -v
check ruby installion on mac

if ruby is not installed on your Mac, you will see this :

command not found: ruby

if your Mac comes with pre-packaged ruby language, you will see the following:

Ruby is installed on mac
ruby 2.6.3p62

You can also use the Which command to know the version and the location of the installed Ruby package.

which -a ruby
location of the installed Ruby package on mac

You can use the pre-installed version of Ruby language for small and even bigger projects. but, I , personally prefer the full-fledged version of both Ruby and Ruby on rails (framework) for my projects.

So, I will show you the exact steps needed to install Ruby on a Mac Operating system:

Yo have to do the following:

  1. Open mac terminal
  2. Install and update the Ruby language package.
  3. Install Xcode (if not already installed) (The official Apple developer tool)
  4. install Homebrew
  5. And, configure settings

First thing We have to do is

Install Homebrew.

Enter and run the following command on your Mac:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Homebrew installs various packages that you will need for software development on your mac OS.

It  installs packages to the own directory and then symlinks their files into /usr/local.

Installing Ruby on Mac

I am installing the 3.1 Ruby version using the below command:

After Homebrew is installed, you can now install Ruby on Mac.

brew install rbenv ruby-build
Installing Ruby on Mac

Configuring Ruby versions on GitHub

Now register on Github if you don’t have an account and we replace the name and email address.

git config --global color.ui true
git config --global user.name "Jasvinder Singh"
git config --global user.email "[email protected]"
ssh-keygen -t rsa -C "[email protected]"

Now run the following command

cat ~/.ssh/id_rsa.pub

and  paste it here.

Now run the github verfication command to see if the syncronization is working properly:

ssh -T [email protected]

You should see something like this:

You've successfully authenticated

Now install Ruby On Rails on Mac

Enter and run the following:

gem install rails -v

Now verify the Ruby on Rails installation with this command:

rbenv rehash

Now both Ruby and Ruby on Rails are installed on your Mac Os.

You can also install the sqlite3 from homebrew for setting up the database for more robust performance:

brew install sqlite3

Install MySQL server and client from Homebrew

brew install mysql

The default user is root and without any password.

That’s it Ruby, Homebrew and Ruby on Rails are now updated and installed on your Mac OS.

Leave a Comment

Don`t copy text!