Ruby 2.4.2 Released, Ruby is a dynamic, object-oriented programming language focused on simplicity and productivity. RVM (Ruby Version Manager) is a tool for installing and managing multiple Ruby versions on single operating systems. This tutorial will help you to install RVM on your system. After that install Ruby 2.4.2 on CentOS, RedHat systems using RVM.
Step 1 – Installing Requirements
First of all, we need to install all required packages for ruby installation on our system using the following command.
yum install gcc-c++ patch readline readline-devel zlib zlib-devel \ libyaml-devel libffi-devel openssl-devel make \ bzip2 autoconf automake libtool bison iconv-devel sqlite-devel
Step 2 – Install RVM
Install the latest stable version of RVM on your system using the following command. This command will automatically download all required files and install on your system.
curl -sSL https://rvm.io/mpapis.asc | gpg --import - curl -L get.rvm.io | bash -s stable
Also, run below command to load the RVM environment.
source /etc/profile.d/rvm.sh rvm reload
Step 3 – Verify Dependencies
Now use the following command to verify all dependencies are properly installed. This will install any missing dependencies on your system.
rvm requirements run Checking requirements for centos. Requirements installation successful.
Step 4 – Install Ruby 2.4
After completing setup of RVM environment lets install Ruby language using the following command. Change Ruby version to below command you need to install.
rvm install 2.4.2
[Sample Output]
Searching for binary rubies, this might take some time. No binary rubies available for: centos/7/x86_64/ruby-2.4.2. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Requirements installation successful. Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.4.2, this may take a while depending on your cpu(s)... ruby-2.4.2 - #downloading ruby-2.4.2, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 12.0M 100 12.0M 0 0 172k 0 0:01:11 0:01:11 --:--:-- 220k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.4.2 - #extracting ruby-2.4.2 to /usr/local/rvm/src/ruby-2.4.2.... ruby-2.4.2 - #configuring.................................................................. ruby-2.4.2 - #post-configuration.. ruby-2.4.2 - #compiling.................................................................................. ruby-2.4.2 - #installing........................... ruby-2.4.2 - #making binaries executable.. ruby-2.4.2 - #downloading rubygems-2.6.14 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 751k 100 751k 0 0 298k 0 0:00:02 0:00:02 --:--:-- 298k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.4.2 - #extracting rubygems-2.6.14.... ruby-2.4.2 - #removing old rubygems......... ruby-2.4.2 - #installing rubygems-2.6.14........................... ruby-2.4.2 - #gemset created /usr/local/rvm/gems/ruby-2.4.2@global ruby-2.4.2 - #importing gemset /usr/local/rvm/gemsets/global.gems............................................... ruby-2.4.2 - #generating global wrappers........ ruby-2.4.2 - #gemset created /usr/local/rvm/gems/ruby-2.4.2 ruby-2.4.2 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-2.4.2 - #generating default wrappers........ ruby-2.4.2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-2.4.2 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri
Step 5 – Setup Default Ruby Version
First of all, check the currently installed ruby versions on your system. So that we can find which version is using currently by the system and which is set to default.
rvm list rvm rubies => ruby-2.3.5 [ x86_64 ] * ruby-2.4.2 [ x86_64 ] # => - current # =* - current && default # * - default
After that use rvm command to setup default ruby version to be used by applications.
rvm use 2.4.2 --default Using /usr/local/rvm/gems/ruby-2.4.2
Step 6 – Verify Active Ruby Version
Using following command you can check the current ruby version is used.
ruby --version ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
Congratulation’s, Finally you have successfully installed Ruby on your system. Read our next articles to deploy Ruby with Apache or Ruby with Nginx web server with simple steps.
References:
1. http://rvm.io/rubies/installing