YouTube Icon

Code Playground.

How to Install Ruby on Ubuntu 18.04

CFG

How to Install Ruby on Ubuntu 18.04

Ruby is quite possibly the most famous dialects today. It has an exquisite linguistic structure and it is the language behind the incredible Ruby on Rails system. 

In this instructional exercise we will show you three distinct approaches to introduce Ruby on Ubuntu 18.04 framework. 

Prerequisites

Prior to beginning with the instructional exercise, ensure you are signed in as a client with sudo advantages . 

Installing Ruby from Ubuntu Repositories

The most straightforward approach to introduce Ruby on your Ubuntu framework is through the adept bundle director. At the hour of composing, the form in the Ubuntu vaults is 2.5.1 which is the most recent stable rendition of Ruby. 

To introduce Ruby from the default Ubuntu storehouses, follow these means: 

To begin with, update the bundles record: 

sudo apt update

Introduce Ruby by composing: 

sudo apt install ruby-full

To confirm that the establishment it was effective run the accompanying order which will print the Ruby variant: 

ruby --version

The yield will look something like this: 

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

Installing Ruby using Rbenv

Rbenv is a lightweight Ruby adaptation the board device which permits you to effectively switch Ruby variants. Naturally Rbenv doesn't deal with introducing Ruby forms so we additionally need to introduce ruby-form which is an apparatus that encourages you to introduce any variant of Ruby you may require. It is accessible as an independent program and as a module for rbenv. 

To introduce Ruby utilizing the Rbenv content, follow these means: 

To begin with, update the bundles record and introduce the bundles needed for the ruby-form instrument to assemble Ruby from source: 

sudo apt update
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev

Next, run the accompanying twist order to introduce both rbenv and ruby-form: 

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

The content will clone both rbenv and ruby-form stores from GitHub to ~/.rbenv catalog. The installer content additionally calls another content which will attempt to check the establishment. The yield of the content will look something like underneath: 

Ubuntu Install Ruby utilizing Rbenv 

Add $HOME/.rbenv/container to the client PATH . 

On the off chance that you are utilizing Bash, run: 

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

On the off chance that you are utilizing Zsh run: 

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

Introduce the most recent stable rendition of Ruby and set it as a default variant with: 

rbenv install 2.5.1
rbenv global 2.5.1

To list all accessible Ruby forms you can utilize: rbenv introduce - l 

Confirm that Ruby was appropriately introduced by printing the rendition number: 

ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

Install Ruby using RVM

RVM is another apparatus for introducing, overseeing and working with numerous Ruby conditions. 

To introduce Ruby utilizing the RVM content, follow these means: 

First introduce the conditions needed for the RVM utility to construct Ruby from source: 

sudo apt update
sudo apt install curl g++, gcc, autoconf, automake, bison, libc6-dev, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, libyaml-dev, make, pkg-config, sqlite3, zlib1g-dev, libgmp-dev, libreadline-dev, libssl-dev

Run the accompanying orders to introduce RVM: 

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

Ubuntu Install Ruby utilizing RVM 

To begin utilizing RVM you need to run the accompanying order: 

source ~/.rvm/scripts/rvm

Introduce the most recent stable variant of Ruby with RVM and set it as the default form with: 

rvm install 2.5.1
rvm use 2.5.1 --default

Confirm that Ruby was appropriately introduced by printing the rendition number: 

ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

For more data about how to deal with your Ruby establishments visit the RVM Documentation page . 

Conclusion

We have indicated you three distinct approaches to introduce Ruby on your Ubuntu 18.04 worker. The technique you pick relies upon your prerequisites and inclinations. Despite the fact that introducing the bundled form from the Ubuntu archive is simpler, the Rbenv and RVM strategies give you greater adaptability for adding and eliminating distinctive Ruby variants on a for each client premise. 

On the off chance that you have any inquiries or criticism, don't hesitate to remark underneath.




CFG