Basics of RVM (Ruby Version Manager)

RVMRVM (Ruby Version Manager) is a command-line tool that manages multiple Ruby versions for your applications on a single device. When different applications are using different versions of Ruby, RVM becomes extremely valuable. It allows an eager developer to switch between projects that require different versions of Ruby. This is a common problem that developers face, and RVM is a great solution to this issue.

RVM was developed by Wayne E. Seguin and Michal Papis and in October 2007. RVM is supported into unix-like operating systems and it is written into Bash and Ruby.

Installing RVM:
Public Key Install:
$ gpg –keyserver hkp:// –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

RVM Install:
$ \curl -sSL | bash -s stable

Features of RVM:
Manages multiple Ruby versions
Less configurations
Easy installations
Can manage gems using gemsets
.rvmrc file or .ruby-version and .ruby-gemset files concept
Can run rubies in multiple terminals

Ruby Commands:
To check available Ruby versions:
$ rvm list known

To install specific Ruby version:
$ rvm install [ruby version] # $ rvm install 2.1

To list all installed Ruby versions:
$ rvm list

To check which version your application is utilizing:
$ rvm current

To use specific installed Ruby version:
$ rvm use [ruby version] # $ rvm use ruby-2.0.0

To set default for specific Ruby version:
$ rvm –default use ruby-2.0.0

If you’re using RVM for your application, you should also be using RVM’s “gemsets.” These gemsets make it seamless for a developer to manage multiple gems across different versions of Ruby.

RVM’s gemsets also uses a cache directory, meaning that only 1 downloaded version of each and every gem exists on a disk, instead of having multiple copies.

Gemset Commands
To create gemset under specific Ruby:
$ rvm use ruby-2.0.0
$ rvm gemset create sampleapp1
$ rvm gemset create sampleapp2

To use a gemset for specific application under specific Ruby:
$ rvm use ruby-2.0.0
$ rvm gemset use sampleapp1
$ rvm gemset use sampleapp2

To use a gemset with your Ruby version:
$ rvm use ruby-2.0.0@sampleapp1
$ rvm use ruby-2.0.0@sampleapp2

To delete a gemset:
$ rvm gemset use sampleapp1
$ rvm gemset delete sampleapp1
It will ask for confirmation but you can skip it with –force command:
$ rvm –force gemset delete sampleapp1

To empty a gemset (remove installed all gems):
$ rvm gemset use sampleapp2
$ rvm gemset empty sampleapp2
It will ask for confirmation but you can skip it with –force command:
$ rvm –force gemset empty sampleapp2

To list gemsets list under specific Ruby version:
$ rvm gemset list

Right now, many developers are choosing RVM to handle multiple Ruby versions for their applications. Developers are preferring RVM for since it is a powerful, yet simple solution.

About The Author :

This Article is written by Codal’s Ruby on Rails Developer. Codal is a full-stack UX Design and Application Development Agency with a focus on emerging technologies like PHP, Java Script, RoR, Python, iOS & Android Development Services.

Basics of RVM (Ruby Version Manager)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s