RVM(Ruby Version Manager) is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems
To install RVM
As a first step install mpapis public key used to verify installation package to ensure security.
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RVM development version
\curl -sSL https://get.rvm.io | bash
RVM stable version
\curl -sSL https://get.rvm.io | bash -s stable --ruby
The following commands are used during setup our rails application.
rvm -v - It shows the rvm version rvm install (ruby-version) - This will install the mentioned ruby version eg: rvm install “ruby-2.2.2”, rvm install “2.3.0” rvm list - To list the installed rubies
rvm use (ruby-version) – Switched to mentioned ruby version
rvm use default - To use default ruby version
rvm get stable – To upgrade the rvm
We can use various Rails versions with each Ruby by creating gemset and then installing Rails within those using the normal gem commands
rvm gemset list - To show all the gemset list rvm gemset create (gemset-name) - To create new gemset rvm gemset use (gemset-name) - To use mentioned gemset for a application rvm gemset delete (gemset-name) - To delete gemset
RVM supports multiple types of files to allow configuring a project for automated ruby switching. In any case, make sure to add those files to your version control systems as it is part of the project configuration
.rvmrc – Shell script allowing full customization of the environment
Ex: .rvmrc file contains the following line
rvm use 2.1.1@nancy --create
This file includes both ruby version and gemset.
.rvmrc not supported for Rails 4 applications.
.ruby-version and .ruby-gemset are used to replace .rvmrc file
.ruby-version contain the ruby version
.ruby-gemset contain the name of ruby gemset.
So it will automatically load the ruby and gemset for the application.