How to upgrade Ruby on CentOS

Last updated on November 25, 2020 by Dan Nanni

Question: I installed a Ruby package with rubygems on CentOS 6.5. When I attempt to start the Ruby application, it fails to start because my CentOS system does not meet the minimum version requirement of Ruby (1.9 and higher). How can I upgrade Ruby on CentOS?

On CentOS 6.5, the default version of Ruby installed is 1.8.7. Some Ruby applications require Ruby version 1.9 and higher, so they cannot run properly on stock CentOS. To upgrade Ruby on CentOS, you can build and install Ruby from the source.

If you already installed ruby and ruby-devel packages with yum before, remove them first before upgrading Ruby.

$ sudo yum remove ruby ruby-devel

Build and install the latest Ruby from the source as follows.

$ sudo yum groupinstall "Development Tools"
$ sudo yum install openssl-devel
$ wget
$ tar xvfvz ruby-2.1.2.tar.gz
$ cd ruby-2.1.2
$ ./configure
$ make
$ sudo make install

Finally, update Rubygems and Bundler.

$ sudo gem update --system
$ sudo gem install bundler

If you have any pre-installed gems with an older version of Ruby, update the gems.

$ sudo gem update

To use the installed Ruby/Rubygems, open a new terminal. Then check the version of installed Ruby and Rubygems as follows.

$ ruby --version
$ rubygems --version


1. When I run gem command after upgrading Ruby, I get the following error.

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

To fix this problem, you need to build and install Ruby extension for OpenSSL from the source as follows.

$ sudo yum install openssl-devel
$ cd ruby-2.1.2/ext/openssl/
$ ruby extconf.rb
$ make top_srcdir="../../"
$ sudo make install top_srcdir="../../"

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean