...

/

Multiple Ruby Versions

Multiple Ruby Versions

Learn how to install RVM and use it for Ruby programs.

How to keep multiple Ruby versions

It is possible for us to keep multiple versions of Ruby on the same computer. If we continue to experiment, we’ll find a way to keep multiple Ruby versions on our filesystem, and all of them will work seamlessly. As we can imagine, this problem already existed a long time ago, when developers realized they needed multiple Ruby versions and some way to switch between them. This is how the Ruby Version Manager (RVM) was born.

RVM is not unique. Similar concepts with slightly different variations exist for other languages, as well. For example, there is the Node Version Manager (NVM) for Node.js. Let’s look closer into RVM.

Installation

Instructions for RVM installation are available at the RVM website, and a summary explains what it is:

“RVM is a command-line tool that allows you to easily install, manage, and work with multiple Ruby environments from interpreters to sets of gems.”

We need to run these two commands to install RVM:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ \curl -sSL https://get.rvm.io | bash -s stable

The installation log says the following:

Installing RVM to /Users/ro/.rvm/
	Adding rvm PATH line … /Users/ro/.bashrc /Users/ro/.zshrc.
	Adding rvm loading line to ... /Users/ro/.bash_profile /Users/ro/.zlogin.
Installation of RVM in /Users/ro/.rvm/ is almost complete:
  • To start using RVM you need to run source /Users/ro/.rvm/scripts/rvm in all your open shell windows, in rare cases, you need to reopen all shell windows.

It recommends running source /Users/ro/.rvm/scripts/rvm (our path is probably different) if we want to use RVM immediately, without restarting a terminal. Then, we can run RVM to see its version:

$ rvm -v
rvm 1.29.4 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

Or help:

$ rvm --help

Usage:

	rvm [--debug][--trace][--nice] <command> <options>

  for example:

	rvm list            	# list installed
...