Setting up single user rvm on ubuntu

RVM is a great tool for Ruby and Ruby on Rails(RoR) developers managing multiple RoR Projects with different ruby and gem configurations. Ubuntu has been growing as a choice for popular development and server Operating system. Lets hop onto our famous 1,2,3 howto format on how to install RVM on an ubuntu machine:
  1. Please ensure that you have curl installed on your system. If not, then its as simple as:
    sudo apt-get install curl
  2. Follow the single user installation instructions given on the rvm site to install rvm onto your system. You will find the instructions here.
  3. After you are done with the single user installation,  on your shell prompt, type
    type rvm | head -1
  4. If you get the following output, then rvm is correctly installed on your system. You can stop reading here and enjoy the magic of rvm on your ubuntu box .. 🙂
    rvm is a function
  5. If you dont get the above output, then we need to perform following additional tasks on your ubuntu box to configure and use rvm properly on your system.
  6. Go to your user’s home directory and open up .profile in your favorite editor such as vi/gedit and add the following lines to the end of file(This basically tells the shell to check if the rvm script exists at the default rvm script location($HOME/.rvm/scripts), and if it exists then executes all the commands in that rvm script files):
     [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function 
  7. The next step is to load the rvm for both interactive and non-interactive shells. This is the step which is missed by most of the beginners and major cause of lot of frustration around troubleshooting the rvm install. Find the following lines in ~/.bashrc file of yours:
  8. # if you see '[ -z "$PS1" ] && return' then you must change this line to:
    if [[ -n "$PS1" ]] ; then ... original content that was below the && return line ...
    fi # <= be sure to close the if. #EOF .bashrc Even if you use zsh you should still adjust the .bashrc as above.
    
  9. And that should be it. The command type rvm | head -l should work perfectly fine now.
Enjoy Multiple ruby and gem versions !!