Install ruby >= 1.8.7 on CentOS release 5.11

0

I’m trying to install SASS, so I need GEMS, which requires Ruby 1.8.7 or higher. The Yum installer installs Ruby 1.8.5. Can’t seem to find a tutorial on the interwebs for successfully installing ruby >= 1.8.7 on this OS.

symlink

Posted 2016-03-07T04:27:07.790

Reputation: 161

Answers

1

The thing you learn about Ruby the hard way when you start out is the system-wide package install is often not the best—nor the recommend—way to stay up to day with Ruby. The whole Ruby world is basically about collaborative—yet per-user—usage and installs so juggling different versions is an accepted norm.

If I were you I would remove/purge that Yum installed version of Ruby and instead use Ruby Version Manager (RVM). It’s easy, nice and a very stable—and well accepted/known—cross-platform way to install and stay up to date with Ruby versions as they come out.

The first step is to run these two commands to actually install RVM. First get the GPG for RVM set on your system like this:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

Then run this command to install RVM:

\curl -sSL https://get.rvm.io | bash -s stable

A heads up but on Ubuntu systems I sometimes have to run this command to install some prerequisites to get the RVM install to compile:

sudo aptitude install libreadline6-dev libyaml-dev sqlite3 libgdbm-dev libncurses5-dev bison pkg-config libffi-dev

Since you are using Yum that command—and package names—might be different, but just a simple “heads up” note in case you run into a snag.

That said, once the dust settles from that process, just run this command to install Ruby 1.8.7:

rvm install ruby-1.8.7

And you are good to go. But fair warning: Ruby version 1.8.7 is fairly ancient in the Ruby world. So you might want to install a more updated version of Ruby such as Ruby 2.3.0. You can install it like this:

rvm install ruby-2.3.0

Once that is done you can check which versions of Ruby you have installed with a command like this:

rvm list

If you want to stick to one version of Ruby over another with RVM just run this command:

rvm --default use 1.8.7

That would make your RVM instal of Ruby 1.8.7 your default version of Ruby. But you can manually switch it to another version like this:

rvm use 2.3.0

More details on the basics right here on the official RVM site.

JakeGould

Posted 2016-03-07T04:27:07.790

Reputation: 38 217

1This was so much easier than using wget from questionable sources. Thank you. – symlink – 2016-03-07T08:10:08.683