How do I manage different versions of Ruby and its associated gems in my system? The obvious answer is RVM. I have been using it for quite a while now and started to put the frequently used commands (fuc) and questions that keep cropping up in my mind in this page. I should come handy as cheatsheet or whatever when I need to quickly get the answer. I very humbly acknowledge that I have been perusing for answers at http://rvm.beginrescueend.com/ but felt the need for a one-stop-page to look for quick answers. So did this page happen. I will keep updating this page with all relevant questions/problems that I have/faced possibly with right answers/solutions.
- What is the command to know if RVM is currently loaded in the opened shell?
$ type rvm | head -n1 (If this shows "rvm is a function", you're good to go) - What is the command to install a specific version of Ruby, say 1.9.1?
$ rvm install 1.9.1 - What is the command to use a specific version of ruby installed in rvm, let's say Ruby 1.9.1?
$ rvm use 1.9.1 or equivalently
$ rvm 1.9.1 - What is the command to find the version of Ruby currently in use by rvm?
$ ruby -v - What is the command to show currently installed rubies?
$ rvm list
Output will be something like below (where => denotes the ruby that is currently being used by ruby): - What is the command to find the installation directory of Ruby in use?
$ which ruby - What is the command to use any Ruby not managed by RVM?
$ rvm system
The above command tells the current shell to act as if you haven't run any "rvm use" commands yet. - What is the command to make one specific version of Ruby as default when a new terminal shell is opened?
$ rvm --default ruby-head - What is the command to switch to RVM's user chosen default ruby?
$ rvm default - What is the command to find which version/flavour of Ruby/JRuby is the default?
$ rvm list default - What is the command to display Ruby information for the current shell?
$ rvm info - What is the command to switch to gems directory for current ruby?
$ rvm gemdir - What is the command to switch to the system gems directory?
$ rvm gemdir system - What is the command to switch to the system user's gems directory?
$ rvm gemdir system user - What is the command to reset to pre-RVM state?
$ rvm reset - What is the command to uninstall RVM installed, say,1.8.7 version of Ruby?
$ rvm uninstall 1.8.7 - What is the command to install gems from system gem dir (osx: /Library/Ruby/Gems/1.8) using current ruby?
$ rvm system ; rvm gemset export system ; rvm 1.8.7 ; rvm gemset import system - [More to come...]
- rvm rubies
- jruby-1.3.1 [ i386-java ]
- jruby-1.5.2 [ i386-java ]
- => ruby-1.8.7-p302 [ i386 ]
- ruby-1.9.1-p378 [ i386 ]
References: