Install latest Ruby version on CentOS/RHEL with RVM

While trying to install rack and passenger on a CentOS 6.8 box I ran into errors…

ERROR:  Error installing rack:
        rack requires Ruby version >= 2.2.2.
ERROR:  Error installing passenger:
        rake requires Ruby version >= 1.9.3.

Seems newer versions of rack and passenger are looking for more recent versions of Ruby than what is installed via CentOS/RHEL RPMs.  I haven’t needed to upgrade Ruby beyond the version that the installed RPMs provide, so I needed to research a bit to get past this road block.

I found a utility called RVM (Ruby Version Manager) that can be used quite easily to upgrade Ruby to pretty much any version you need.  I chose to install the latest stable version of Ruby.  RVM also allows you to have multiple versions of Ruby installed on your system and quickly switch between them.

It’s pretty easy to use.  Here’s what I did:

  • Install some required RPMs
yum -y install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel sqlite-devel
  • Download and install the latest stable version of RVM
curl -sSL get.rvm.io | bash -s stable
  • Set up environment for Ruby
source /etc/profile.d/rvm.sh
rvm install 2.3.1
  • Set default version once installation completes
rvm use 2.3.1 --default
  • Finally, check that the version is correct
ruby --version

It’s that easy! Once I updated Ruby to the latest version I was able to successfully install both Rack and Passenger. Problem solved!

Thanks to the references I used to get this working:

RVM: Ruby Version Manager

How to Install Ruby 2.1.8 on CentOS & RHEL using RVM

Install Puppet Server CentOS 6.5/6.4