• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Ruby on CentOS 8 / RHEL 8

Written by Admin, Updated On May 10, 2020
centos, ruby
How to Install Ruby on CentOS 8

Ruby is popular, dynamic and flexible open source programming language. It has an elegant syntax that is natural to read and easy to write. We’ll show how to install Ruby from CentOS default repositories and using the Rbenv and RVM scripts on CentOS 8 system. Choose the installation method that is most appropriate for your setup and environment.

Installing Ruby from the CentOS repositories#

It’s very straightforward to install Ruby from CentOS repositories. At the time of writing, the version in the standard CentOS repositories is 2.5.5.

To install the ruby package, execute following command as non-root user with sudo privileges:

sudo dnf install ruby

Verify the Ruby version, once the installation is complete, type:

ruby --version

That’s done!

Install Ruby with Rbenv#

Rbenv is a Ruby version management tool that allows you to switch Ruby versions easily. By default Rbenv doesn’t handle installing Ruby versions so we also need to install ruby-build that will help you to install specific version of Ruby. Follow the below instruction as root or sudo user to install Ruby with Rbenv:

Now, install dependencies for installation of rbenv and ruby-build:

sudo dnf install git wget gcc bzip2 openssl-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel

After that, simply clone rbenv GitHub repository into the ~/.rbenv folder:

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

Next, run the following commands to set up rbenv:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

Now download the ruby-build plugin into the plugins folder of rbenv as follows:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

The ruby-build plugin adds the install command to rbenv.

To get a list of all Ruby versions that can be installed with rbenv enter:

rbenv install -l

To install Ruby version 2.7.1 and set it as default version, type:

rbenv install 2.7.1
rbenv global 2.7.1

Verify installation by issuing below command:

ruby -v

Install Ruby using RVM#

RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

Install the dependencies required to build Ruby from source:

sudo dnf install curl gcc bzip2 openssl-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel

Run the following commands to add the GPG key and install RVM:

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

To start using RVM, type:

source ~/.rvm/scripts/rvm

Install the latest stable version 2.7.1 of Ruby with RVM and set it as the default version:

rvm install 2.7.1
rvm use 2.7.1 --default

Verify that Ruby installed properly by checking it’s version:

ruby -v

Conclusion#

We shown you two methods to install Ruby on CentOS 8 system. The method depends on your requirements and preferences.

If you have any problem or suggestion please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install And Use Tmux
Next Article   How to Install MariaDB on Ubuntu 20.04

Related Posts

  • How to Install Php 8 on CentOS 8

    How to Install PHP 8 on CentOS 8

    January 27, 2021
  • How to Install Python 3.9 on CentOS 8

    How to Install Python 3.9 on CentOS 8

    December 31, 2020
  • How to Install GIMP 2.10 on CentOS 8

    How to Install GIMP 2.10 on CentOS 8

    December 30, 2020

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Python 3.11 on Debian 11
    How to Install Python on Debian 11 January 25, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook