Javatpoint Logo
Javatpoint Logo

Install RVM Ubuntu

RVM supports almost all Windows and Unix-like systems (with Bash or Cygwin on Windows on Ubuntu). The basic needs are curl, gpg2, bash, and overall the tools of the GNU version, but RVM is trying to auto-detect it and then install anything which is required.

RVM is short for Ruby Version Manager. It is a platform of software for UNIX-like operating systems developed for managing more than one Ruby installation on similar devices. The entire environment of Ruby including the interpreter of Ruby, installed RubyGems, and documentation will be partitioned. Then, a developer can switch between the distinct versions for working on various projects with distinct requirements of the version.

The standard interpreter of Ruby, in inclusion to MRI, RVM works as an installer for several other Ruby implementations. These include Rubinius, Maglev, IronRuby, MacRuby, mruby, jruby, Topaz, Ruby Enterprise Edition, and GoRuby (an interpreter that is optimized for code golf). RVM provides its support for the installation of MRI patched versions.

RVM facilitates many features for Ruby gems organization from "gemsets", a group of gems that is isolated by a namespace and related installation of Ruby. Gemsets could be related to projects/directories from the use of the RVM exclusive file, i.e., .rvmrc. A substitution for using the file, i.e., .rvmrc (and the basic purpose however user-specific .jrubyrc) and its format is the application of the .ruby-gemset and .ruby-version files that are compatible with other RVMs such as chruby and RBenv. Using the file additionally requires trusting for preventing unauthorized code execution, while .ruby-version doesn't.

Types of RVM

Two types of RVM are available in common use: rbenv and RVM. They take distinct methods to the issue of using two or more Ruby versions, but the outcome is the same. We can easily utilize two or more Ruby versions on a similar system.

Which RVM should we use?

Partly, it depends on our needs and preferences, but almost all people can choose one and begin using it. The two systems functionally perform every task almost every developer needs. There is less in the way of aspects to suggest a single version over others.

If we are using a Linux system or Cloud9, we suggest RVM because it is simple to install and run. For a Mac, some issues are also there with RVM. However, almost all need to do with previous editions of Ruby. For that cause, we may wish to utilize Rbenv for a Mac. If we have installed Homebrew, the simplest method to install Rbenv is using the command, i.e., brew install.

Working of RVM

The core of RVM is a group of directories where RVM stores every version of Ruby, its related tools (including irb and gem), and its gems. All directories are specific to a provided Ruby version. If we need the 2.3.1 version of Ruby, RVM utilizes the files in the directory, i.e., ruby-2.3.1. If we need the 2.2.2 version of Ruby, RVM brings the files from the directory, i.e., ruby-2.2.2.

Remember that the typical Ruby executables are detected in the Rubies subdirectories of the main directory of RVM, while gems are detected inside the gems subdirectory. Also, remember that the numbers of the Gem version can be different between Rubies. In this type of case, the 2.2.2 version of Ruby uses the 0.43.1 version of Rubocop, while the 2.3.1 version of Ruby uses the 0.45.0 version of Rubocop.

  • RVM specifies a shell function called rvm. Our shell utilizes this function to run the disk-based command, i.e., rvm.
  • Complex reasons when utilizing the shell function are also there, but the primary reason is that the function can change our environment, but a disk-based command can't.
  • When we execute rvm use VERSION to modify the Ruby version we wish to use, we actually appeal to the rvm function.
  • It changes our environment so that several Ruby commands appeal to the appropriate version.
  • For example, rvm use 2.2.2 changes our PATH variable so that the command, i.e., ruby, uses the installed Ruby in the directory, i.e., ruby-2.2.2.
  • It makes other modifications, but the PATH modification is the most observable.
  • If we want to execute rubocop from the directory, i.e., Ruby 2.2.2, we can tell RVM to utilize Ruby 2.2.2; after that, execute the command, i.e., rubocop.
  • The system finds the rubocop command in our PATH and executes the one it finds first.
  • As the RVM directories appear in our PATH early, the system detects the correct rubocop command that applies to Ruby 2.2.2.
  • The rubocop command resides in the /usr/local/rvm/gems/ruby-2.2.2/bin directory.

RVM complexity

RVM is a complicated system. Sometimes, this complexity can get in the path of stability, especially because it changes system commands, such as cd, by appealing to them by shell functions, while issues rare when we have it active. Several moving parts are there that can possibly go wrong. Probably, they would not go wrong, but the possibilities remain.

The most probable problem with RVM is that we get confused about which Ruby version we are running or whether we update or install Gems using the false gem command. If trying to detect an RVM issue, we first need to make sure that we are using the correct Ruby version. These types of issues are easier to find, then we can analyze Gem versioning issues.

RVM Commands with Explanation

  • echo $PATH: This command confirms that the directories, i.e., {RVM PATH}/gem/rubies-{VERSION}/bin and {RVM PATH}/rubies-{VERSION}/bin are available in our PATH, and mentioned before other directories that may include programs with a similar name.
  • rvm info: This command shows a longish information list about the latest RVM environment. The same as gem evn inside the info provided, but differently formatted and adds RVM-specific information.
  • rvm repair all: This command repairs files that aid RVM in handling the different rubies. It may be helpful if RVM seems broken completely.
  • rvm fix-permissions: On RVM files, this command can repair the permissions. It may be useful if we accidentally run the sudo command to install, update, or modify RVM or its Gems or rubies.
  • rvm current: It shows the running Ruby version. This command adds the gemset name in the result if we use gemsets.
  • rvm get latest: It downloads and installs the latest RVM version. It is most helpful when we are using an unfamiliar or a new aspect that may not be correctly working or available in our current version.
  • gem list: It shows a list of every installed Gem for the latest Ruby and their version numbers.
  • gen env: It shows configuration info about our RubyGems system.

Explanation of the Ruby installation using RVM

We can install and configure Ruby Version Manager in three different ways which are listed and explained below:

1. Single-User Installations (suggested): For a separated install in the $HOME directory of a user, not for sudo or root.

2. Multi-User Installations (recommended for server administrators): For the installation usable by every user on the system. Also, it used to be known as the System-Wide install. Using this kind of installation without knowing can lead to a big risk of security.

Note: Single-User Installation supersedes the Multi-User Installation.

3. Mixed-Mode Installations: For the installation usable by every user on the system with separated gemsets/rubies in the $HOME directory of a user. The instructions of the installation are the same as for the installations of Multi-User, the only difference is the environment of the user.

RVM Basics

RVM does not only make installing more than one Ruby runtimes/interpreters consistent and easy, it facilitates aspects such as gemsets that are not supported on almost all Ruby installs. RVM enables us to use different types of rubies in a way that would not mess with our existing install of Ruby and enabling us to concurrently execute more than one type of Ruby in isolated terminals.

Community Maintained Project

Ruby Version Manager is supported and maintained by the community via pull requests and issue trackers:

  • on all projects in the GitHub organization of RVM,
  • especially the issue tracker of the RVM project.


RVM enables us to deploy all projects with its completely dedicated and self-contained environment from the specific ruby version, every way down to the definite set of needed gems for running our application. Having a definite set of gems ignores the version issue conflicts among projects which can lead to difficult to trace bugs and hours of hair loss.


Ruby Version Manager can decrease the complexity of several Ruby development angles from its API of the command-line. We can have self-contained and identical environments in our Development, Q/A, Staging, CI, and Production environments with RVM. No more hidden appreciations, if it implements for one of them, then it will implement in each of them.

We can immediately and reliably push Modifications from a single environment to another with the named gemsets. RVM is for the applications of Ruby, not only for Rails. All the applications that are Ruby-based will get benefit from our use of RVM.


Ruby Version Manager enables us for easily testing both escape and upgrade paths very consistently and easily. We can execute the rake tasks, test suite, gem and benchmark commands against more than one version of Ruby at the same time with RVM. It means that we can easily ensure our applications implement in Ruby 1.8.X, MRI 1.9.1, REE, jruby, etc.... and quickly disclose any area where they don't.

Management of Gem

RVM contains an extremely formative Gem Management System which is known as Named Gem Sets. The "gemsets" of RVM make handling gems across more than one Ruby version a non-issue. RVM enables us to add a small file of text to the repository of our application, rather than checking in several gems which will inflate the size of a repository needlessly.

Additionally, the gemset management of RVM applies a basic directory of cache, so only a single downloaded version of all gems resides over a disk instead of many copies. RVM supports to ensure that every Ruby aspect is completely included in user space, non-root, strongly encouraging safer use.

Use of the rubies of RVM facilitates excellent system security and hence decreases risk and reduces overall downtime of the system. Additionally, since each process executing at the user level, a composed Ruby process can't compose the whole system.

Getting started with RVM

First of all, we must ensure that we install RVM.

Configuration of Post Install

When we log in either by a local shell or ssh account, RVM would be loaded like a function. We can use one of the below links in case of any issue as a reference to configure our terminal:

  • Screen Workflow
  • Zsh iTerm
  • XTerm
  • Ubuntu on Windows
  • LXTerminal
  • Konsole
  • Gnome Terminal

Best Practices of RVM

The below is a set of best practices and tips that have been confirmed to be useful in making the process of development convenient while practicing RVM.


  1. Use files, i.e., rvmrc for all of our individual projects.
    An rvmrc (project-specific) makes it convenient for automating our common workflow. It does not only enable us to automatically switch many rubies when we work on our app, but it also makes it convenient to bootstrap environments automatically.
  2. Check our rvmrc in source control.
    By checking the rvmrc file of the project in source control with our app, we are ensuring every user has a consistent environment if they are using our project and RVM, also by automating installs of gemset and the like.
    Also, we can make bootstrapping any project happen by coding in the project directory, given we have the export rvm_project_rvmrc=1 file in the $HOME/.rvmrc file.
    On top of this, we can also automatically enable our deployments setting up our application-specific platform even when we are applying passenger.
  3. Apply per-project gemsets
    In this list, per-project gemsets are applied such that all applications have their different environment of a gem, supporting us to ignore problems that come about through conflicting versions. It involves applying something like "[email protected]" rather than "2.1.1" if choosing a Ruby (e.g., inside our rvmrc).
  4. Setup with RVM if possible
    Developing using RVM is not only a good idea, if possible, it's also a nice idea to set up our application with RVM. It brings about the common benefits of an application-specific platform, but also makes it convenient for tracking down the bugs (version-specific) that appear in production later over in development.
    Primarily, it is since it ensures a consistent platform reasonably between the two. RVM can support us with it by the command, i.e., 'rvm upgrade' if it comes time for upgrading our Ruby even better.
  5. Integrate RVM in tools of choice

Configuration of RVM

RVM contains a configuration directory positioned in the $rvm_config_path file which for a common installation like a user to their directory, i.e., $HOME would be positioned in the ~/.rvm/config/ file.


RVM includes a collection of the false that are recorded within the file which is mentioned below:

The above file is substituted all time we upgrade RVM so don't edit it.

Override default settings

Also, RVM contains a directory for all users override positioned in the $rvm_path/user file. We need to place the accurate key=value in that folder's db file to override the default settings of RVM.

Then, RVM will apply these settings rather than the defaults of RVM.

Preparing our OS for installation

There are 3 libraries we need to install before installing RVM:

  • GPG: It is an encryption program to verify the application source
  • Bash: It is a program for running the download script.
  • Curl: It is a program for downloading the script which will install RVM.

Most OSes will come using these pre-installed packages, so examine first before downloading.

With the command terminal

We will be referencing the command line or terminal during this article. That is the name of our application for most OSes that enables us to input commands that will be interpreted via the system. MacOS contains a terminal emulator, Windows contains a console, and Linux also contains a console.

Verify the source of the installation

Cryptographically, RVM signs all releases which needs validation on the downloads. We will configure the related keys RVM needs for verifying the signature by executing the below command in the command line:

The above command will add the provided keys to our local key store and enable RVM installation verification and shows the following output when execute:

This output displays that two important public keys are added to the local store. The release will be seen against these 2 keys for verifying the file which was come from the source if RVM is installed.

Install RVM

The installation process of RVM has slightly distinct steps for Ubuntu operating system as compared to the other operating systems. Windows operating system will only be supported when using the Subsystem of Windows for Linux and applies similar instructions as for Linux (except Ubuntu) and macOS.

Install in Ubuntu

Ubuntu operating system contains a dedicated package that is available for installing with the help of a package manager, i.e., apt-get.

Installing the needed libraries for using Personal Package Archies

We need to install the software-properties-common Ubuntu package to permit the inclusion of the Personal Package Archive (or PPA).

We need to open our command line window and execute the following command:

Install RVM Ubuntu

Install RVM Ubuntu

The above commands will update the package manager, i.e., apt-get with the help of the current references, and then install the library, i.e., software-properties-common which permits the inclusion of the RVM PPA.

We need to execute the following command for verifying if the old command was run successfully:

Install RVM Ubuntu

The above command will query the package manager for verifying the provided package was correctly installed. Our command-line window will show the following message if this command was run successfully.

Include PPA for RVM

Specifically, add the Personal Package Archive for RVM with the help of the following command. This command will add a repository including the RVM binary and permit installation:

Install RVM Ubuntu

The above command will add the repository to the internal list of Ubuntu. It holds for enabling the RVM installation.

Installing RVM

We need to update our installer and then install RVM by executing the following command in our terminal:

Install RVM Ubuntu

This command will install the application of RVM and provides the application the accurate permissions. The option -y will skip the confirmation request on install.

Verify the installation is correct using RVM

We will execute the following command in the terminal to start with RVM for the very first time. It just requires to be executed once after the installation process:

The above command will run the script and permit us to execute RBM in the latest terminal in our terminal. We need to instruct RVM for returning the currently installed release to ensure that our RVM is correctly working by executing the following command in the terminal:

Install RVM Ubuntu

The above command will display the latest RVM version installed on our operating system.

Installing Ruby

We will use the "rvm install <version-number>" command for installing a Ruby Version with the help of RVM. We need to execute the following command in the terminal to install a specific version of Ruby:

Install RVM Ubuntu

This command may compile the binaries of Ruby or apply precompiled binaries from the source depending on our operating system. It might take time to finish if compiling using source.

We will execute the following command in the terminal for checking this installation is implemented correctly:

Install RVM Ubuntu

It will list every installed Ruby version handled by RVM.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA