简体   繁体   中英

Amazon Linux latest ruby

Amazon Linux 2012.03 now comes with ruby 1.9.3

To install it (as per the docs)

sudo yum install ruby19

But ruby -v shows 1.8.7 . How would I switch it over 1.9.3 (If its already there there would be no need to use RVM yes?)

The right way to do this on Amazon Linux is:

sudo yum update (to get latest version of Amazon Linux (2013.09 at time of this answer)
yum install ruby19 
alternatives --set ruby /usr/bin/ruby1.9

Supplementing @baboonWorksFine's answer, there are a number of 1.9 commands that can be symlinked as their undecorated equivalents. What I did was:

sudo -s
for f in /usr/bin/*1.9
do
  ln -s $f ${f%1.9}
done

That way, you don't accidentally miss any commands that need aliasing.

If you do this:

ls -l /usr/bin/ruby*

you will probably see this:

lrwxrwxrwx 1 root root    7 Apr 26 18:27 /usr/bin/ruby -> ruby1.8
-rwxr-xr-x 1 root root 3720 Mar 29 08:29 /usr/bin/ruby1.8
-rwxr-xr-x 1 root root 3888 Mar 29 12:26 /usr/bin/ruby1.9

This is well self explained. So what you wanna do is:

rm /usr/bin/ruby && ln -s /usr/bin/ruby1.9 /usr/bin/ruby

Here is one simple solution and cleaner.

alternatives --config ruby

That will list all versions of Ruby you installed through yum. All you have to do is choose the number listed there and hit enter.

Ruby version 1.9 should be available under the name ruby19 or ruby1.9 . ruby is just a symbolic link that points to default version of ruby.

I used @Ian Dickinson's answer, but added an "f" to the ln options to force it to overwrite the existing link. So the code is:

sudo -s
for f in /usr/bin/*1.9
do
  ln -fs $f ${f%1.9}
done

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