Install Ruby Version Manager (RVM) on CentOS 6

CentOS 6 ships with updated version of Ruby (version 1.8.7), but does not include the flexibility provided by the Ruby Version Manager (RVM). You will definitely want to use RVM, as it lets you easily manage the roll-forward and roll-back of Ruby and associated Gemsets. Assuming you begin with a Minimal installation of CentOS 6, here is how you install RVM:

1) Install the base packages Ruby needs (all 115 of them)

yum groupinstall "Development Tools"

2) Install NTP and force a time update.

yum install ntp
ntpdate tick.gatech.edu

3) Install zlib and sqlite3

yum install zlib zlib-devel sqlite-devel

4) Download and install RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

UPDATE:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Once installed, log out of your SSH session, then log back in.
5) Verify your RVM installation. You should see “RVM is a function” echoed back.

type rvm | head -1

6) Install Ruby version 1.9.2

rvm install 1.9.2

7) Set version 1.9.2 to be the default Ruby version.

rvm use 1.9.2 --default

8) Verify your version of Ruby is 1.9.2

ruby -v

9) Install Rake gem

gem install rake

10) Install Rails gem

gem install rails

11) Verify Rails install

rails -v

12) Install SQLite gem

gem install sqlite3

You should now have a fully functioning Ruby development environment for your CentOS Linux server.

12 Replies to “Install Ruby Version Manager (RVM) on CentOS 6”

  1. thank you. I needed this to get some ruby-based tools installed on centos, and didn’t know enough about ruby to get gem installed and working.

  2. Hi, I am new to CentOS (6.0.) and followed your blog post to the dot. Unfortunately it rendered my installation somehow useless. All PATHs are gone and the ruby installation fails because of a missing “tput”.. The system was a mess after bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

    I then logged in and out, restarted and so on.. Nothing really helps. Any help would be appreciated.

  3. there are additional installs required, which I orignally overlooked, which have to be
    run, embedded in SYSTEM NOTES when step 4 is executed.

    SYSTEM NOTES:

    If you do not wish to enable reading of per-project .rvmrc files, simply set:
    export rvm_project_rvmrc=0
    within either your /etc/rvmrc or $HOME/.rvmrc file, then log out and back in.

    In case your shell exits on entering directory with freshly checked out sources
    you should update .rvmrc file, and replace any `exit ` with `return `.

    You _must_ read ‘rvm requirements’ for additional OS specific requirements for
    various rubies, and native-extension gems. Expect failures until those are met!

    For screen users, please do not forget to read https://rvm.beginrescueend.com/workflow/screen/.
    You will need to add ‘shell -/bin/bash’ to your $HOME/.screenrc to properly load RVM.

    Installation of RVM to /usr/local/rvm/ is complete.

    Requirements for Linux ( CentOS Linux release 6.0 (Final) )

    NOTE: ‘ruby’ represents Matz’s Ruby Interpreter (MRI) (1.8.X, 1.9.X)
    This is the *original* / standard Ruby Language Interpreter
    ‘ree’ represents Ruby Enterprise Edition
    ‘rbx’ represents Rubinius

    bash >= 4.1 required
    curl is required
    git is required (>= 1.7 recommended)
    patch is required (for ree and some ruby-head’s).

    To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
    then you must install and use rvm 1.8.7 first.

    NOTE: To all Multi-User installers – DO NOT forget to add your users to the ‘rvm’ group.
    The installer does not auto-add any users to the rvm group. Admins must do this.
    Group memberships are ONLY evaluated at login time. Log them out, then back in.

    Additional Dependencies:
    # For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
    ruby:
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ## NOTE: For centos >= 5.4 iconv-devel is provided by glibc

    # For JRuby, install the following:
    jruby: yum install -y java
    [root@localhost ~]# type rvm | head -l
    head: invalid option — ‘l’
    Try `head –help’ for more information.
    bash: type: rvm: not found
    [root@localhost ~]# type rvm | head -1
    bash: type: rvm: not found
    [root@localhost ~]# type rvm | head
    bash: type: rvm: not found

    [root@localhost ~]# yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel

    Loaded plugins: fastestmirror, refresh-packagekit
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.netelligent.ca
    * epel: fedora.mirror.nexicom.net
    * extras: centos.mirror.netelligent.ca
    * updates: centos.mirror.netelligent.ca
    Setting up Install Process
    Package gcc-c++-4.4.4-13.el6.i686 already installed and latest version
    Package patch-2.6-6.el6.i686 already installed and latest version
    Package readline-6.0-3.el6.i686 already installed and latest version
    Package zlib-1.2.3-25.el6.i686 already installed and latest version
    Package zlib-devel-1.2.3-25.el6.i686 already installed and latest version
    Package 1:make-3.81-19.el6.i686 already installed and latest version
    Package bzip2-1.0.5-7.el6_0.i686 already installed and latest version
    Package autoconf-2.63-5.1.el6.noarch already installed and latest version
    Package automake-1.11.1-1.2.el6.noarch already installed and latest version
    Package libtool-2.2.6-15.5.el6.i686 already installed and latest version
    Package bison-2.4.1-5.el6.i686 already installed and latest version
    No package iconv-devel available.
    Resolving Dependencies
    –> Running transaction check
    —> Package libffi-devel.i686 0:3.0.5-3.2.el6 set to be updated
    —> Package libyaml-devel.i686 0:0.1.3-1.el6 set to be updated
    –> Processing Dependency: libyaml = 0.1.3-1.el6 for package: libyaml-devel-0.1.3-1.el6.i686
    –> Processing Dependency: libyaml-0.so.2 for package: libyaml-devel-0.1.3-1.el6.i686
    —> Package openssl-devel.i686 0:1.0.0-4.el6_0.2 set to be updated
    –> Processing Dependency: krb5-devel for package: openssl-devel-1.0.0-4.el6_0.2.i686
    —> Package readline-devel.i686 0:6.0-3.el6 set to be updated
    –> Processing Dependency: ncurses-devel for package: readline-devel-6.0-3.el6.i686
    –> Running transaction check
    —> Package krb5-devel.i686 0:1.8.2-3.el6_0.7 set to be updated
    –> Processing Dependency: libcom_err-devel for package: krb5-devel-1.8.2-3.el6_0.7.i686
    –> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.8.2-3.el6_0.7.i686
    –> Processing Dependency: libselinux-devel for package: krb5-devel-1.8.2-3.el6_0.7.i686
    —> Package libyaml.i686 0:0.1.3-1.el6 set to be updated
    —> Package ncurses-devel.i686 0:5.7-3.20090208.el6 set to be updated
    –> Running transaction check
    —> Package keyutils-libs-devel.i686 0:1.4-1.el6 set to be updated
    —> Package libcom_err-devel.i686 0:1.41.12-3.el6 set to be updated
    —> Package libselinux-devel.i686 0:2.0.94-2.el6 set to be updated
    –> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-2.el6.i686
    –> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-2.el6.i686
    –> Running transaction check
    —> Package libsepol-devel.i686 0:2.0.41-3.el6 set to be updated
    –> Finished Dependency Resolution

    Dependencies Resolved

    =============================================================================================================================================================
    Package Arch Version Repository Size
    =============================================================================================================================================================
    Installing:
    libffi-devel i686 3.0.5-3.2.el6 base 18 k
    libyaml-devel i686 0.1.3-1.el6 epel 84 k
    openssl-devel i686 1.0.0-4.el6_0.2 updates 1.1 M
    readline-devel i686 6.0-3.el6 base 134 k
    Installing for dependencies:
    keyutils-libs-devel i686 1.4-1.el6 base 28 k
    krb5-devel i686 1.8.2-3.el6_0.7 updates 1.2 M
    libcom_err-devel i686 1.41.12-3.el6 base 29 k
    libselinux-devel i686 2.0.94-2.el6 base 135 k
    libsepol-devel i686 2.0.41-3.el6 base 64 k
    libyaml i686 0.1.3-1.el6 epel 52 k
    ncurses-devel i686 5.7-3.20090208.el6 base 642 k

    Transaction Summary
    =============================================================================================================================================================
    Install 11 Package(s)
    Upgrade 0 Package(s)

    Total download size: 3.5 M
    Installed size: 8.3 M
    Downloading Packages:
    (1/11): keyutils-libs-devel-1.4-1.el6.i686.rpm | 28 kB 00:00
    (2/11): krb5-devel-1.8.2-3.el6_0.7.i686.rpm | 1.2 MB 00:03
    (3/11): libcom_err-devel-1.41.12-3.el6.i686.rpm | 29 kB 00:00
    (4/11): libffi-devel-3.0.5-3.2.el6.i686.rpm | 18 kB 00:00
    (5/11): libselinux-devel-2.0.94-2.el6.i686.rpm | 135 kB 00:00
    (6/11): libsepol-devel-2.0.41-3.el6.i686.rpm | 64 kB 00:00
    (7/11): libyaml-0.1.3-1.el6.i686.rpm | 52 kB 00:00
    (8/11): libyaml-devel-0.1.3-1.el6.i686.rpm | 84 kB 00:00
    (9/11): ncurses-devel-5.7-3.20090208.el6.i686.rpm | 642 kB 00:02
    (10/11): openssl-devel-1.0.0-4.el6_0.2.i686.rpm | 1.1 MB 00:03
    (11/11): readline-devel-6.0-3.el6.i686.rpm | 134 kB 00:00
    ————————————————————————————————————————————————————-
    Total 257 kB/s | 3.5 MB 00:13
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Installing : libyaml-0.1.3-1.el6.i686 1/11
    Installing : libcom_err-devel-1.41.12-3.el6.i686 2/11
    Installing : libsepol-devel-2.0.41-3.el6.i686 3/11
    Installing : libselinux-devel-2.0.94-2.el6.i686 4/11
    Installing : ncurses-devel-5.7-3.20090208.el6.i686 5/11
    Installing : keyutils-libs-devel-1.4-1.el6.i686 6/11
    Installing : readline-devel-6.0-3.el6.i686 7/11
    Installing : libyaml-devel-0.1.3-1.el6.i686 8/11
    Installing : libffi-devel-3.0.5-3.2.el6.i686 9/11
    Installing : krb5-devel-1.8.2-3.el6_0.7.i686 10/11
    Installing : openssl-devel-1.0.0-4.el6_0.2.i686 11/11

    Installed:
    libffi-devel.i686 0:3.0.5-3.2.el6 libyaml-devel.i686 0:0.1.3-1.el6 openssl-devel.i686 0:1.0.0-4.el6_0.2 readline-devel.i686 0:6.0-3.el6

    Dependency Installed:
    keyutils-libs-devel.i686 0:1.4-1.el6 krb5-devel.i686 0:1.8.2-3.el6_0.7 libcom_err-devel.i686 0:1.41.12-3.el6 libselinux-devel.i686 0:2.0.94-2.el6
    libsepol-devel.i686 0:2.0.41-3.el6 libyaml.i686 0:0.1.3-1.el6 ncurses-devel.i686 0:5.7-3.20090208.el6

  4. Thank you so much for taking the time to write this up. I am a n00b and I cut and pasted each line and it works perfectly, with the exception of step (7) which I think has an extra period (type) after the 1.9.2.

    is: rvm use 1.9.2. –default

    should be: rvm use 1.9.2 –default

    Anyway, I have my Mac Rails running fine, but things were a mess following Hartl’s setup for Rails 3.1 (not his fault), then I found this, and 10 minutes later I’m finished and ready to code!!

Leave a Reply

Your email address will not be published. Required fields are marked *