Search This Blog

October 19, 2010

FAQ on RVM - Ruby Version Manager


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.
  1. 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)  
  2. What is the command to install a specific version of Ruby, say 1.9.1?
    $ rvm install 1.9.1
  3. 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
  4. What is the command to find the version of Ruby currently in use by rvm?
    $ ruby -v
  5. What is the command to show currently installed rubies?
    $ rvm list
  6.  Output will be something like below (where => denotes the ruby that is currently being used by ruby):
       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 ]
  7. What is the command to find the installation directory of Ruby in use?
    $ which ruby
  8. What is the command to use any Ruby not managed by RVM?
    $ rvm system
  9.  The above command tells the current shell to act as if you haven't run any "rvm use" commands yet.
  10. What is the command to make one specific version of Ruby as default when a new terminal shell is opened?
    $ rvm --default ruby-head
  11. What is the command to switch to RVM's user chosen default ruby?
    $ rvm default
  12. What is the command to find which version/flavour of Ruby/JRuby is the default?
    $ rvm list default
  13. What is the command to display Ruby information for the current shell?
    $ rvm info
  14. What is the command to switch to gems directory for current ruby?
    $ rvm gemdir
  15. What is the command to switch to the system gems directory?
    $ rvm gemdir system
  16. What is the command to switch to the system user's gems directory?
    rvm gemdir system user
  17. What is the command to reset to pre-RVM state?
    $ rvm reset
  18. What is the command to uninstall RVM installed, say,1.8.7 version of Ruby?
    $ rvm uninstall 1.8.7
  19. 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
  20. [More to come...]
References: