2

I just did apt-get install ruby.1.9.1, installing it successfully. Now when I do ruby -v, it's still 1.8.7. Why won't it use the newly installed version? I don't know why, but I can't find anything via google on how to manage ruby versions without rvm. I know rvm is awesome, but in this case it has to be without rvm.

Can anybody help me?

Brian
  • 14,610
  • 7
  • 35
  • 43
rails_has_elegance
  • 1,590
  • 4
  • 21
  • 37
  • 3
    It probably installed it as `ruby19`. You can rename the old `ruby` executable to `ruby18` and then make a symbolic link from `ruby` to `ruby19`. – Casper Dec 04 '12 at 15:07
  • do you know where these files are to find? thanks in advance! – rails_has_elegance Dec 04 '12 at 15:08
  • 3
    Type `which ruby` to find the location of the ruby executable. Type `which ruby19` to find `ruby19`. It could also be named `ruby1.9` or `ruby1.9.1` or something similar. – Casper Dec 04 '12 at 15:17
  • well in my usr/lib/ruby i got 1.8 and 1.9.1. However I kinda dont know how to do what you explained, im still kindof new to Linux and everything. If possible, could you tell me which executable exactly you mean? and that symbolic link is meant from which file? sorry for these many questions.. – rails_has_elegance Dec 04 '12 at 15:47
  • I'll write it in an answer. Just a sec... – Casper Dec 04 '12 at 15:50

2 Answers2

4

This is just an example of how to resolve this issue. The paths and file names might be different on your system, but you should get the idea from here:

# First locate the original ruby
> which ruby
/usr/bin/ruby   # <- Your path might be different

# Then locate ruby19
> which ruby19
/usr/bin/ruby19

# Move the old ruby out of the way
> mv /usr/bin/ruby /usr/bin/ruby_old

# Link ruby to the new ruby (ruby19)
# ln -s is used to create a new symbolic link. See "man ln" for more info.
> cd /usr/bin
> ln -s ruby19 ruby

Now you should have:

/usr/bin/ruby_old                 # The old executable
/usr/bin/ruby -> /usr/bin/ruby19  # The new link
/usr/bin/ruby19                   # The new executable

Note: it's easy to break your system ruby if you're not careful using this method. That's why RVM is usually a better solution if you have the choice. You can leave a comment if something breaks, and I will try and improve the instructions.

Casper
  • 33,403
  • 4
  • 84
  • 79
  • Assuming `~/bin` is in his `$PATH` he could also just do ``ln -s "`which ruby19`" ~/bin/ruby`` – Abe Voelker Dec 04 '12 at 16:02
  • @AbeVoelker Thx. Yes that would work also. But if he wants ruby19 installed system-wide then he needs to link it in the system folders. – Casper Dec 04 '12 at 16:06
-13

It's better installing Ruby via RVM, and switch to certain version via RVM,

rvm use ruby-1.9.2 --default
Mayur Shah
  • 3,344
  • 1
  • 22
  • 41
Healer
  • 290
  • 1
  • 7