Centos 6.5 and Ruby 1.9.3 via Software Collections

I wanted to cut the amount of repositories that my systems were running and I recently came across Red Hats Software Collections (SCL). Software collections is a relatively new system that allows you to run some newer versions of popular packages including ruby, php, postgreSQL and more. I needed a newer version of Ruby (1.9.3) for my systems because I use a backup system that’s written in ruby from Michael van Rooijen. I know that Ruby 1.9.3 might not be new enough for some but it works for me. The following is a quick guide on how to get Centos 6.5 and Ruby 1.9.3 via software collections.

The standard CentOS repositories ships with software collections and its very easy to get them running. You can do so by running the following command.

yum install -y centos-release-SCL

This will then give you access to the standard SCL’s that ship with CentOS/RHEL. You can build your own software collections if you like but I won’t go into that with this post. Now you will have the newer versions available to install such as ruby193. Run the following to install ruby193.

yum install -y ruby193

I run minimal installs so I never have any other versions of software installed unless I need them so if I was to run ruby -v on the command line I would get the following:

[root@machine1 ~]# ruby -v
-bash: ruby: command not found

Now you might think that ruby hasn’t installed, it has it’s just not part of your path or current session. To enable ruby run the following command.

[root@machine1 ~]# source /opt/rh/ruby193/enable
[root@machine1 ~]# ruby -v
ruby 1.9.3p448 (2013-06-27) [x86_64-linux]

As you can see we’ve now got access to ruby 1.9.3 from the software collections. There is a whole bunch of ruby193 packages available you can find them using search with yum. As I don’t use the standard ruby packages at all I want to make the SCL version my default version. The above commands are great for the current session but you would have to run source  every login.  A nice way to make sure that this is working across logout and reboots is to put the source command in the profile.

echo "source /opt/rh/ruby193/enable" | sudo tee -a /etc/profile.d/ruby193.sh

This will make it available as default for all users.

2 thoughts on “Centos 6.5 and Ruby 1.9.3 via Software Collections”

Comments are closed.