简体   繁体   中英

upgrade ruby version without rvm

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?

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.

最好通过RVM安装Ruby,然后通过RVM切换到特定版本,

rvm use ruby-1.9.2 --default

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM