Bobo
Bobo

Reputation: 9163

Why won't my rvm allow me to switch to an alternative Ruby?

Ubuntu already has Ruby 1.8.7 installed. Then I installed rvm and used it to install Ruby 1.9.2, which is the version I want to use. However, ruby -v always returns 1.8.7.

How do I get rvm to use Ruby 1.9.2?

bxu@vm-bxu:~$ rvm use 1.9.2
Using /usr/share/ruby-rvm/gems/ruby-1.9.2-p320
bxu@vm-bxu:~$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

Upvotes: 3

Views: 1381

Answers (3)

Todd A. Jacobs
Todd A. Jacobs

Reputation: 84343

The Problem

RVM does its own installation magic, but in Ubuntu's case it doesn't always install to the right Bash startup file. You probably don't actually have RVM running properly; even though it's sort of installed.

The Fix

You need to make sure the following two lines are at the BOTTOM of your ~/.bashrc file.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
export PATH=$PATH:$HOME/.rvm/bin

Then restart your terminal emulator or log back in. Note that sourcing ~/.bashrc has been known not to work in some cases, so this step will save your sanity.

RVM should now be working properly. The last step is to set your default Ruby.

rvm --default use 1.9.2

Important Edit

As I've just been reminded, RVM breaks Ubuntu login shells by installing ~/.bash_login, which overrides your Ubuntu ~/.profile in login shells. Move the code over to your ~/.bashrc if you haven't already done so, then remove or rename ~/.bash_login.

Upvotes: 3

mpapis
mpapis

Reputation: 53158

on Ubuntu you need to enable login shell in your terminal emulator, we have a quite good documentation for this at rvm site: https://rvm.io/integration/gnome-terminal/

Upvotes: -1

MBHNYC
MBHNYC

Reputation: 1258

From the terminal:

rvm use 1.9.2

Upvotes: 0

Related Questions