RVM (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://keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
Public Key Install:
$ gpg –keyserver hkp://keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
RVM Install:
$ \curl -sSL https://get.rvm.io | bash -s stable
$ \curl -sSL https://get.rvm.io | 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
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 check available Ruby versions:
$ rvm list known
To install specific Ruby version:
$ rvm install [ruby version] # $ rvm install 2.1
$ rvm install [ruby version] # $ rvm install 2.1
To list all installed Ruby versions:
$ rvm list
$ rvm list
To check which version your application is utilizing:
$ rvm current
$ rvm current
To use specific installed Ruby version:
$ rvm use [ruby version] # $ rvm use ruby-2.0.0
$ rvm use [ruby version] # $ rvm use ruby-2.0.0
To set default for specific Ruby version:
$ rvm –default use ruby-2.0.0
$ rvm –default use ruby-2.0.0
Gemsets
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.
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 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
$ 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
$ 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
$ 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
$ 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
$ rvm gemset list
Conclusion
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.
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.
No comments:
Post a Comment