VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app

Installing and Using Rvm on Mac OS X, Creating Gemsets and Reverting to Original Environment

       

What is RVM and why should you use it? RVM is a Ruby interpreter, version management tool. In short, it enables you to switch between different versions and releases of Ruby (for instance, version 1.8.6, 1.8.7, jruby 1.9.2, ruby enterprise edition) on the same machine, while associating different gems with each version of the ruby interpreter. This is super useful and awesome. If you want to play with Rails 3 and Ruby 1.9.1, for 5 minutes, and then want to switch back to your production apps, which are running on Rails 2.3.5 and Ruby 1.8.7, you can do so with a single command from the terminal. With RVM this is a fairly simple process so there is no reason not to install it. You can also revert back to your system settings (not using RVM) with a single command. After all Rails is just a gem, so you can easily create and manage different RVM "gemsets", (sets of different gems), for the different versions of Ruby (rubies as RVM refers to them) you have installed.

Installing RVM


bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Next you have to add rvm to your bash profile

place in ~/.bash_profile as the very last line

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

To check everything went well


type rvm | head -n1
Should tell you "rvm is a function"

How to add ruby, pass it the version to install


rvm install 1.8.7
*The current terminal session will load this environment. New sessions will not. To use a version of ruby and set it as the default, pass it the --default option

rvm use 1.8.7 --default

Next create a gemset, which will make available different gems for different versions


rvm gemset create rails_2_3_5

When you run "gem list", you should see nothing!


gem install rails -v=2.3.5

Set a default rvm and default gemset, specify which gemset with the @ sign and include the --default option


rvm use 1.8.7@rails_2_3_5 --default


which gem
gem list 
ruby --version
rails --version 

And to get back to where you started and revert to using your original ruby setup


rvm system

For upgrading your version of RVM check out this post I wrote http://seanbehan.com/ruby/how-to-upgrade-rvm-on-mac-os-x/

Finally, you can create a .rvmrc file and put it in any directory and when you cd into that directory the environment specified in the file will be loaded automatically. This way you don't have to remember the version and gemsets and type them into the console. All you have to do is put the ruby version and gemset name in the file like so

ruby1.8.7@rails2.3.5

You'll be prompted to trust the .rvmrc file the first time, type "y" for yes. Also, subdirectories will inherit this .rvmrc so you can just put it in the parent directory like


rails2/
     .rvmrc
     app1
     app2
rails3/
     .rvmrc
     app1
     app2

And both app1 and app2 will use the .rvmrc environment while your rails3 directory apps will load the environment in its directory!

More information available here: http://rvm.beginrescueend.com/rvm/install/ http://www.stjhimy.com/posts/4 http://eddorre.com/posts/installing-rails-3-beta-4-using-rvm

Tagged w/ #development #environment #ruby #rvm #setup #version managementmac os x #ruby