How to install Ruby in your local environment

Subscribe to my newsletter and never miss my upcoming articles

If you're new to Ruby and don't have an idea of what Ruby is on a generic level, you can refer to my previous article.

Let's get into installing Ruby on our local environment.

Installing Ruby

Ruby is easy to work with and a beginner-friendly language. But sometimes installing the language on your system and setting up the local environment for development, might tend to be serious to many folks who are doing it for the first time. This article clearly covers how to install and use Ruby.

  • Installing Ruby on Unix Based OS - macOS and Linux
  • Installing Ruby on Windows

Installing Ruby on Unix Based OS - macOS and Linux

Ruby Version Manager(RVM) is a command-line tool that helps in installing, managing, and working with multiple Ruby environments.


  1. Open your Terminal
  2. Install the GPG keys
  3. Install RVM
  4. Install the Ruby version using RVM

Install the GPG keys

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

GPG keys allow for the secure transmission of information between parties and can be used to verify that the origin of a message is genuine.

bash: gpg2: command not found

If you face this, install gpg2 using the commands from here.

Install RVM

Type the following command in your terminal.

curl -sSL | bash -s stable

After RVM is successfully installed, add the PATH to RVM in your .bashrc or .zshrc. You also need to run the below command to start using RVM

source /home/USERNAME/.rvm/scripts/rvm

Here, USERNAME is the username of the current user on the system.

Install the Ruby version you want using the below command

rvm install ruby_version

Here ruby_version is the version of ruby you want to install, eg. 2.7.1

  • Using rbenv

Alternative to RVM, you can also use rbenv for installing and managing Ruby. There is a clear cut installation procedure on their documentation.

Installing Ruby on Windows

Although there is Ruby Installer for Windows to work with Ruby, it is recommended that you install and work with on Windows Sub System for Linux(WSL). Some dependencies may trigger errors when installing on Windows, so using WSL allows you to work on the business logic for the software you're developing and not having to fix gem incompatibilities.

What is WSL?

The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup.

-Microsoft Docs

Microsoft Docs has clear documentation on enabling WSL and installing a Linux distribution. You can find the document here.

After installing the preferred Linux distribution, you can follow the same process done above for macOS and Linux.

Checking if Ruby is installed

$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

This should print out the current Ruby version being used by the system. If you're using multiple Ruby versions,

$ rvm list
* ruby-2.3.0 [ x86_64 ]
=> ruby-2.7.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

You can access the Ruby Interactive Console(irb), by just giving irb

$ irb
2.7.1 :001 > puts " Hello WOrld"
 Hello WOrld
 => nil
2.7.1 :002 >

Let me know in the comments if you use any other way to install Ruby for your local development :)


  1. Microsoft Docs

No Comments Yet