- go to the command line and your home directory
- Type the following to install RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
- 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
- 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
- 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 ]
- Then I can type
rvm use 1.9.2 #to switch to this version of ruby
- 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
- Now restart bash, by typing
- We will install gems we want to be available to all gemsets in the @global gemset
- And install bundler
gem install bundler
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