Site icon installvirtual

Install ruby 2.4 with rbenv on CentOS/RHEL 7/6

In this tutorial, we will install ruby 2.4 with rbenv on Centos /RHEL 7/6.

Ruby is a dynamic, interpreted, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro “Matz” Matsumoto in Japan.

According to the creator, Ruby was influenced by Perl, Smalltalk, Eiffel, Ada, and Lisp. It supports multiple programming paradigms, including functional, object-oriented, and imperative.

Read Also: Install ruby 2.4 with rvm on Centos/RHEL 7/6

Prerequisites

There are few prerequisites that you need to install before.

yum install git

Install rbenv

Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production. Put rbenv to work with Bundler for painless Ruby upgrades and bulletproof deployments.

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.

echo'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

Set up rbenv in your shell.

~/.rbenv/bin/rbenv init

Execute the following command to install ruby-build.

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Verify installation

You can use the rbenv doctor to verify if it’s installed properly.

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash

Install Ruby 2.4.1

Now after successful installation of rbenv now we will install ruby and manage ruby using rbenv.

rbenv install 2.4.1
Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
Installing ruby-2.4.1...
Installed ruby-2.4.1 to /root/.rbenv/versions/2.4.1

Set default Ruby

After installation of ruby 2.4.1, we will set it up as default ruby version.

rbenv global 2.4.1

Use the above command to set ruby version globally.

rbenv local 2.4.1

Use the above command to application-specific ruby version.

Check Ruby Version

ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
which ruby
/root/.rbenv/shims/ruby

List Ruby Versions

To list all installed ruby versions use the following command.

rbenv versions
system
* 2.4.1 (set by /root/.rbenv/version)

Now you have successfully installed ruby 2.4.1.

If you have any issue using this tutorial please feel free to comment below.

 

Exit mobile version