How to install RVM on MacOS X Snow Leopard
anand posted this on 30 Dec 2010
Managing multiple versions of rubies and ruby gems is a very difficult task. One of your projects might be using Ruby 1.9.2, while your other old project might be using Ruby 1.8.7. Adding to this complexity, each of your project might be using different versions of a same ruby gem. (For example rails 3.0.1, rails 2.3.8, rails 2.3.5).
RVM was created to solve this problem. RVM is surprisingly easy to use with its simple set of commands. I will explain how to use it in the next blog post. Here, I will explain how to install it.
Before installing rvm, make sure that you have installed XCode developer tools in your mac. Apple distributes the XCode developer tools in CD with every Mac. You can even download it from Apple developer site for free.
To Install RVM
1. Open your terminal, copy and paste the following command in it. Then press enter.
2. Then, go to your home directory
3. Edit your .profile file using your favorite editor.
4. Copy and paste the below line at the end of .profile file
5. Save it and exit the file. (This step varies for different editors. For nano it is Ctrl-o and then Ctrl-x )
6. Run the following command to reload your shell settings.
7. Confirm whether rvm was installed properly in your system by typing the following command in terminal.
You should see the following output.
Your rvm is installed now.
Installing Rubies:
Ruby-1.8.7-p174 (Ruby 1.8.7 patch level 174) is installed by default in MacOSX. This is called system ruby. If you want to check its version in your mac, you can type this command and see for yourself.
Now, lets install ruby 1.8.7 and ruby 1.9.2 using RVM.
1. To install ruby 1.8.7, type this command in your terminal.
Now, rvm will download ruby v1.8.7 source code, compile and install it automatically. This process will take some time depending on your system and internet speed.
2. Installing ruby 1.9.2 is by the same command.
Note: Installing MacRuby, JRuby is similar with a few tweaks. You can refer the documentation for installing them.
After installing, you can check by typing the following command
and it will give the following output for me.
jruby-1.5.3 [ x86_64-java ]
macruby-0.7.1 [ x86_64 ]
=> ruby-1.8.7-p302 [ x86_64 ]
ruby-1.9.2-p0 [ x86_64 ]
Using Rubies:
To start using ruby 1.8.7, you need to give this command in terminal,
and to start using 1.9.2, you need to give a similar command
To make one ruby version as default, you need to give command like
You can always check the version you are using currently by one of the following commands.
or
Please refer the documentation for more advanced use cases.
~