Installing RVM and Ruby on CentOS 7

The @base Ruby version is ancient and actually EOL’d, so you should really use RVM for your Ruby needs. The good news is that it’s really simple.


Chances are, you already have Ruby installed from the EL repo. And possibly some gems, too. In this case:

# remove old versions
gem cleanup
# remove gems that came via `gem install`
for x in $(gem list | cut -f 1 -d ' '); do gem uninstall $x -x -I -a; done
# remove packaged gems and all of ruby
yum erase ruby*



Before you can obtain up-to-date Ruby, you need RVM. So let’s get that.

# import the necessary GPG keys
gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
# install RVM
curl -L | bash -s stable
# spare the logout/login
source /etc/profile.d/


Now we have the tools, install Ruby itself. Pick the Ruby version needed for your application, then (in this example I use 2.5):

export RUBY_VER='2.5'
rvm install ${RUBY_VER}
rvm use ${RUBY_VER} --default

Easy as pie.



rvm get stable
rvm reload


Query the list of available versions:

rvm list known

Install a branch with:

export RUBY_VER='2.6'
rvm install ${RUBY_VER}
rvm use ${RUBY_VER} --default
rvm cleanup all

If you no longer need the old version:

rvm remove 2.5
Tags: , , ,