Table of Contents
Introduction
The Ruby Version Manager (RVM) is a command line tool that simplifies installing and managing multiple Ruby environments on a single host. This allows easy access to new versions of Ruby or past versions of Ruby for code compatibility testing.
Requirements
- Ubuntu
- Single server instance with external connectivity
Install RVM
The curl
command is necessary for the RVM installation if not already available.
apt-get -y install curl
The RVM installation script will attempt to automatically download and install additional development packages required to compile Ruby. These can be manually installed ahead of time if necessary.
apt-get -y install patch gawk g++ gcc make libc6-dev libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev
The RVM installation can now be started.
curl -L get.rvm.io | bash -s stable
If an error stating "GPG signature verification failed" appears, the on-screen instructions should describe retrieving and installing the RVM signature key. For example:
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
The RVM installation process will need to be restarted after the signature key is installed.
curl -L get.rvm.io | bash -s stable
Install Ruby
RVM can be started by loading the RVM environment for the current session.
source /etc/profile.d/rvm.sh
Ruby can now be installed by specifying the version. In this case, Ruby 2.1.4 will be installed.
rvm install 2.1.4
While the latest version of Ruby is recommended, additional versions can be installed along side each other.
rvm install 1.9.3
To view which versions of Ruby are currently installed through RVM.
rvm list
Set Ruby Version
The desired Ruby version can be set for the current session and new sessions.
rvm use 2.1.4 --default
The Ruby version should now show 2.1.4.
ruby --version
If another version of Ruby was installed using RVM, then that version can be made accessible for the current session.
ruby use 1.9.3
If Ruby was previously installed from the Linux distribution repository, access to that version can be easily be restored.
rvm system --default