Setup Ruby

Setup Ruby on your own computer


Getting Ruby setup on your own computer is the first step to writing and running your own Ruby programs. Installing Ruby also gives you access to interactive ruby (irb), which lets you play with Ruby in real time.

This article will help you make sure you have Ruby 2.2.0 installed on your computer, then show you ways to play around with Ruby to prove it works. Let’s get started:

Installing Ruby (Mac)

Did you know that while you were blazing through the Codecademy Ruby course on the web, you had a Ruby interpreter built in to your Mac operating system the whole time? Let’s check out which version of Ruby you have.

  • Open the Terminal app. It usually lives in Applications/Utilities/
  • Inside of your Terminal, type ruby -v.

This command will tell you which version of Ruby you have installed. We want to make sure you have Ruby 2.2.1 or above. If your version is below 2.2.1, take the steps in the Install RVM section. If you’re already above 2.2.1, feel free to move on to the Wake Up, Ruby! section.

Install RVM (Ruby Version Manager) (Mac)

RVM, short for Ruby Version Manager, is a command line tool that allows you to install and manage different versions of Ruby on your computer. RVM is a very popular tool for managing Ruby versions, so let’s get it set up!

  • To install RVM, go to Terminal, and copy in this line exactly: \curl -sSL | bash -s stable

  • Hit enter, and wait for a moment while your computer installs RVM.

  • Once RVM is done installing, we can use it to install Ruby 2.2.1. To do this, type: sudo rvm install 2.2.1

After you hit enter, your command line will prompt you to type in your computer’s password. Type it in and hit enter. You should see Ruby begin to download and install within your command line window.

Note: Installing a new version of Ruby will take some time. It’s the perfect time for a coffee break.

Once Ruby is installed, let’s set Ruby 2.2.1 as the default Ruby version on your computer. Do this by typing this into your command line: rvm use --default 2.2.1

If you experience problems getting Ruby installed with RVM, check out the documentation on the RVM website here

Once you’ve got Ruby 2.2.1 set as your default Ruby version, head down to the Wake Up, Ruby! section.

Installing Ruby (Windows)

Everything you need to get Ruby up and running on Windows can be done through RubyInstaller. Download the installer for Ruby version 2.2.1 here. We recommend downloading the non-64 bit version. Open up the program, and click next through the installer. Once the installer is finished, search for a program named Start Command Prompt with Ruby. This is a program created by the Ruby installer in the last step, and will allow you to run Ruby commands through your command line interface.

Wake Up, Ruby!

You’ve woken up Ruby. Now let’s warm it up. Type this into your command line:


Which should output this:


You’re now in an “interactive Ruby environment.” Almost every rule you learned about the Ruby universe applies here. Do some math with operations like +, -, *, /, %. Write an if/else statement or create an array and iterate over it with .each. Experiment with what’s possible.

Pro Tip: irb is an extremely useful tool for refreshing your memory about how Ruby behaves. If you have a question about how a string method works, or you’d like to see the difference between the outputs for puts “Hello, world!” vs. print “Hello, world!”, irb is the place to experiment.

Life-Saving Ruby Terminal Commands

  • ctrl + c: interrupts the current process – extremely useful for stopping endless loops
  • ctrl + d: ends the irb session and pops you back into your terminal shell

Wrapping up

Now that you have Ruby installed and working on your own computer, you can run Ruby programs. To do this, use the command line to navigate to the directory where a Ruby file exists. Then, type in ruby to the command line, followed by the name of the Ruby file you’d like to run. For instance, if the ruby file was named test.rb, you would write ruby test.rb in your command line. Hit enter, and see your Ruby program spread its wings!


Codecademy Team

The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.

Meet the full team