Ruby is popular programming language among large number of developers. Rails is the framework to run ruby language. Ruby language was created by Yukihiro “Matz” Matsumoto and first published in 1995. This article will help you to install ruby on rails on Ubuntu, Debian and Linuxmint operating systems using RVM. RVM is the Ruby Version Manager helps for installing and managing Ruby language on systems.
Step 1 – Install RVM
First of all, install the latest stable version of RVM on your system using following command. This command will automatically download all required files and install on your system.
# apt-get install curl
Before installing RVM first we need to import public key in our system then use curl to install rvm in our system.
# curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - # curl -sSL https://get.rvm.io | bash -s stable
After installing RVM first we need to set up rvm environment using below command. so that current shell takes new environment settings.
# source /etc/profile.d/rvm.sh
Install Ruby Dependencies
Install all the dependencies for installing Ruby automatically on system. Run below command on terminal.
# rvm requirements
Step 2 – List Available Ruby Versions
Get a list of available versions of Ruby language. You can install any version of your choice or requirements showing in list.
# rvm list known
[ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.10] [ruby-]2.2[.7] [ruby-]2.3[.4] [ruby-]2.4[.1] ruby-head
Step 3 – Install Ruby Version
RVM is useful for installain of multiple Ruby versions on single system. Use the following command to install required Ruby on your system. As shown below example will install Ruby 2.4.1 on your system.
# rvm install
Searching for binary rubies, this might take some time. Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.4.1.tar.bz2 Checking requirements for ubuntu. Requirements installation successful. ruby-2.4.1 - #configure ruby-2.4.1 - #download % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 16.4M 100 16.4M 0 0 45285 0 0:06:20 0:06:20 --:--:-- 38499 ruby-2.4.1 - #validate archive ruby-2.4.1 - #extract ruby-2.4.1 - #validate binary ruby-2.4.1 - #setup ruby-2.4.1 - #gemset created /usr/local/rvm/gems/[email protected] ruby-2.4.1 - #importing gemset /usr/local/rvm/gemsets/global.gems................................... ruby-2.4.1 - #generating global wrappers........ ruby-2.4.1 - #gemset created /usr/local/rvm/gems/ruby-2.4.1 ruby-2.4.1 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-2.4.1 - #generating default wrappers........
Step 4 – Setup Default Ruby Version
Use rvm command to set up default ruby version to be used by applications. You can install multiple versions by running command multiple times with different versions using above command. Now select which version you want to use.
rvm use 2.4.1 --defaultUsing /usr/local/rvm/gems/ruby-2.4.1
Step 5 – Check Ruby Version
Using following command you can check the current ruby version is used.
ruby --versionruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
Step 6 – Install Rails
We can install latest stable release version of Rails by running following command. It will install Rails in global gemset, So that all applications share the same version of Rails.
# gem install rails # rails -v
Or we can get a specific version of Rails by defining –version during installation. Visit here to get available rails versions.
# gem install rails --version=5.1.4
I hope above steps will help you for installing multiple Ruby version using RVM and Rails versions.