Last updated on November 25, 2020 by Dan Nanni
rubygemson 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-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 http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz $ 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="../../"