Question

I'm on Linux Ubuntu 12.04, and I first installed Ruby 1.9.2.

After I tried installing rvm to use Octopress, ruby --version in bash results in ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

How can I use RVM with ruby 1.9.2?

I don't really understand what RVM is all about...

Was it helpful?

Solution

RVM is a version manager which enables you to decide which of multiple installed Ruby versions you want to use in your current shell session. RVM does this by providing a shell function named rvm which can be used to switch between versions in the current session. This changes environment variables, especially the GEM_HOME and PATH, to match the currently selected Ruby installation.

Every installed Ruby version can be selected by a specific identifier string. If you had a system-wide Ruby installation already before you installed RVM, that one should be referenced by the string system. The newly installed version in your case should be called 1.9.2.

To make RVM work as intended, it is necessary to load the rvm shell function into your shell. How to do this is described in the RVM Installation Documentation in section 2 - "Load RVM into your shell sessions as a function".

You can see if the shell function is correctly loaded when the command type rvm | head -n1 responds with:

rvm is a shell function

If not correctly loaded it will tell you something like this:

rvm is /home/someone/.rvm/bin/rvm

If you finally have it working you can switch your active Ruby version with commands like rvm 1.9.2 or rvm system. You can get a list of all Ruby versions and their identifier strings recognized by RVM by the command rvm list.

You can also specify which Ruby version shall be enabled in all new shell sessions from the beginning by issuing the following command once:

rvm --default 1.9.2

OTHER TIPS

The 1.9.2 version you installed first is not accessible from rvm.

While working with rvm, only the list of rubies installed through rvm is served. The previously installed versions of ruby - while still present in the filesystem - are not included.

With the steps you have done so far, you have a 1.9.2 version installed in one location, and a 1.8.7 version installed as part of rvm.

Install 1.9,2 version by running the rvm install 1.9.2 command. After that, when you run the rvm list command, you should see an output similar to the following:

$ rvm list

rvm rubies

   ruby-1.8.7-p358 [ i686 ]
=* ruby-1.9.2-p320 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

You can switch between different versions of ruby managed by rvm with the rvm use 1.8.7 / rvm use 1.9.2 commands.

Here's a short blogpost with a good intro to rvm: Get started right with RVM

Perhaps you have not yet switched to the ruby version with:

rvm use 1.9.2 (assuming you did rvm install 1.9.2)

for a more general explanation I gave an answer here which might help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top