Skip to content

Instantly share code, notes, and snippets.

@bullfight
Created August 21, 2011 08:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bullfight/1160338 to your computer and use it in GitHub Desktop.
Save bullfight/1160338 to your computer and use it in GitHub Desktop.
setup rvm

Start by installing RVM

  1. go to the command line and your home directory
cd ~/
  1. Type the following to install RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
  1. Then type (adds line to your bash profile so that it loads when you launch bash) I'm adding this to both .bash_profile and .bashrc, because I'm not sure which is best.
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" Load RVM function' >> ~/.bash_profile

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" Load RVM function' >> ~/.bashrc

# This is an opt in to managing project dependencies through .rvmrc, we will make this a little later
echo 'rvm_project_rvmrc=1
rvm_project_rvmrc_default=1' >> ~/.rvmrc
  1. The Type the following (may take a bit). This installs ruby in a way that is accessible from RVM (Ruby Version Manager).
rvm get head
rvm reload
rvm install 1.8.7
rvm install 1.9.2
  1. Now you can do things like, and get
rvm list

#rvm rubies
#
#   ruby-1.8.7-p334 [ x86_64 ]
#   ruby-1.9.2-p290 [ x86_64 ]
  1. Then I can type
rvm use 1.9.2 #to switch to this version of ruby
  1. We will define a default configuration of 1.9.2, and because I assume you will be working with rails 3 a gemset called rails3_0_10
rvm use 1.9.2@rails_3_0_10 --default
  1. Now restart bash, by typing
bash
  1. We will install gems we want to be available to all gemsets in the @global gemset
rvm use@global
  1. And install bundler
gem install bundler

Where does this come in most useful?

In every rails project, I create a file called .rvmrc to define the version of ruby and a gemset specific to that application so for example

cd ~/rails_app
rvm --rvmrc --create 1.9.2@arbitrary_rails_app_name

this says, use ruby 1.9.2 and a gemset called arbitrary_rails_app_name in this way, it allows you to define the version of ruby that should be used for the given application, and it also allows you to define a gemset just for that application, that way you don't have say an older gem version interfering with your app

Now, when you cd into a rails application that has a .rvmrc file, it will automatically load the correct version of ruby and the correct gemset.

When you first cd into a directory with a .rvmrc, you will get a message asking if you trust the .rvmrc file, confirm that you do.

Ok that is it for Ruby Version Management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment