Installing RVM
There are three very different ways to use RVM.
- As a User
- As Root (be *very* sure you know what you are doing... - like user, but into /usr/local/rvm)
- System Wide (Multiple Users, Installed via Root).
If you wish to install rvm system wide, please read our system-wide installation guide which takes a slightly different approach to the method highlighted below.
Don't forget to set your default ruby after the installation so that your command line opens with ruby enabled.
Install not working? Please ensure you've read the troubleshooting notes at the bottom of this page. Namely, you need to ensure returns in your shell profiles are converted to ifs.
There are at least 3 ways to install RVM.
1. GitHub Repository (recommended)
To install / update from the github repository (recommended):
∴ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
What this script essentially does is the following, with some extra checks and tweaks:
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install
Note that if you are behind a firewall (slower, but it should work), change the git:// to http:// like this:
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 http://github.com/wayneeseguin/rvm.git && cd rvm && ./install
2. Installing / updating the latest rvm from the latest source tarball
∴ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-latest )
What this script essentially does is the following, with some extra checks and tweaks:
version=$(curl http://rvm.beginrescueend.com/releases/stable-version.txt);
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src/ && curl -O http://rvm.beginrescueend.com/releases/rvm-${version}.tar.gz | tar zxf - && cd rvm-${version} && ./install
3. Installing from a gem (not recommended)
Although we suggest installing the rvm gem for the ruby api part of rvm, we discourage the use of it for actually installing rvm itself - this primarily being since rvm updates are typically done via:
∴ rvm update
Versus the gem alternative of:
∴ gem update rvm && rvm-install
Meaning the gem version and the rvm version may both differ greatly. Also, installing as a gem requires you use an existing ruby. For the few cases where you must use a gem, you can simply do "gem install rvm" followed by running the rvm-install binary:
∴ gem install rvm # Install the RVM gem # Adjust the path below for whever your system gem bin directory is located ∴ ~/.gem/ruby/1.8/bin/rvm-install # Install RVM, adds hooks for bash & zsh
If rvm-install is not found at the path listed it is likely because your users gem home is not in your path. You can find out the path to use by running
∴ gem env gemdir
This will show something like /Users/wayne/.gem/ruby/1.8
Post Install
The first time you install RVM, you must put the following line into your profile at the very end, after all path loads etc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
Doing so ensures rvm is loaded as a function (versus as a binary), ensuring commands such as rvm use work as expected. Please note that you can confirm this worked correctly by opening a new shell and running:
∴ type rvm | head -n1
If this was performed correctly, you should see:
rvm is a function
Next, you can manually load the new code into your current shell and start using RVM ! w00t!
∴ source ~/.rvm/scripts/rvm
Be sure to install any dependencies for your operating system by running:
∴ rvm notes
The following script will boostrap git + RVM assuming that you have curl & sudo installed. It will also install (last line) several common rubies.
#!/usr/bin/env bash # Install git mkdir -p $HOME/.rvm/src && cd $HOME/.rvm/src && version=1.7.1.1 curl -O http://kernel.org/pub/software/scm/git/git-$version.tar.gz; tar xzf git-$version.tar.gz cd git-$version && ./configure --prefix=/usr/local && make && sudo make install # Install RVM bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) # Install some rubies source "$HOME/.rvm/scripts/rvm" rvm install ree,1.9.2-head,jruby
Troubleshooting your Install
-
If you open a new shell and running:
∴ type rvm | head -n1
does not show "rvm is a function", rvm isn't being sourced correctly.
-
Do NOT 'return' from inside the .bashrc file or else RVM will be prevented from working properly - That is to say, if your .bashrc contains "&& return", e.g, ubuntu in particular has
[ -z "$PS1" ] && return
you'll need to convert it into an if statement - e.g, in this case we change the given line into
if [[ -n "$PS1" ]]; then
indent everything below it one level and then add a trailing "fi" on a new line. Once that is done, we add the source line as noted above after the fi you added. E.g, this:
[ -z "$PS1" ] && return # Some code here... e.g. export HISTCONTROL=ignoreboth
would become:
if [[ -n "$PS1" ]]; then # Some code here... e.g. export HISTCONTROL=ignoreboth fi [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
-
Ensure that rvm is the last thing sourced in all of your shell profiles - e.g. it is sourced in the user specific profile after any environment variables, especially PATH are set. Otherwise, the values you set be trampled when you switch rubies.