Sarstime
Sarstime

Reputation: 184

why my ruby version is still an old version on ubuntu after I installed ruby1.9.2?

I am newbie to ubuntu and ROR. After installed latest ruby1.9.2 with apt-get, type "ruby -v" it still shows up old version ruby1.8.7. I tried to reinstall with rvm, nothing changed.

As mentioned in similar question, I tried to remove ruby, and reinstall ruby1.9.1-full... still the same thing...

What else I can do about this?

Upvotes: 4

Views: 3852

Answers (5)

danvitoriano
danvitoriano

Reputation: 1431

I think it is because the package of Ruby version at apt-get repository is an old version.

I suggest use rbenv to install the latest version.

Here is a great tutorial using rbenv to install the latest Ruby version from Digital Ocean:

https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04

Upvotes: 1

Rémi
Rémi

Reputation: 8342

ubuntu uses a something called alternatives for chosing between two version of similar executable. Running

    sudo update-alternatives --config ruby

and chosing the ruby you want should do the trick

Upvotes: 8

Mithun Sasidharan
Mithun Sasidharan

Reputation: 20950

sudo apt-get install ruby1.9

should do the trick.

You can find what libraries are available to install by

apt-cache search <your search term>

So I just did apt-cache search ruby | grep 9 to find it.

You'll probably need to invoke the new Ruby as ruby1.9, because Ubuntu will probably default to 1.8 if you just type ruby.

Upvotes: 0

Joshua
Joshua

Reputation: 5514

Sounds like you are using rvm, but still referencing system ruby. To switch, you have to tell rvm what version to use.

rvm use 1.9.2 

This will switch your current environment only. So ruby -v in your current shell will use the right version. (you should probably go with 1.9.3, FWIW) If you want to always use that ruby be default, you type:

rvm use 1.9.2 --default

If you want to switch back to system ruby, you can use:

rvm use system

Upvotes: 1

Lukas Stejskal
Lukas Stejskal

Reputation: 2562

I'm using RVM myself, but if I remember correctly, ruby1.8 and ruby1.9 can be installed side by side on Ubuntu. ruby is just a symbolic link which points to version 1.8 by default - which should be called ruby1.8 and stored in the same directory. 1.9 will be called ruby1.9.

So just find where ruby symbolic link is (whereis ruby) and change it so it points to ruby1.9.

sudo rm /path/ruby
sudo ln -s /path/ruby1.9 /path/ruby 

Upvotes: 4

Related Questions