Programming Books

Main Menu

  • Home
  • Phyton programming
  • Java programming
  • Php programming
  • C++ programming
  • Additional Topics
    • Programming industry
    • Privacy Policy
    • Terms and Conditions

Programming Books

Header Banner

Programming Books

  • Home
  • Phyton programming
  • Java programming
  • Php programming
  • C++ programming
  • Additional Topics
    • Programming industry
    • Privacy Policy
    • Terms and Conditions
Java programming
Home›Java programming›3 Ways to Install Ruby on Ubuntu 22.04 LTS Jammy

3 Ways to Install Ruby on Ubuntu 22.04 LTS Jammy

By Brandy J. Richardson
May 5, 2022
0
0

Learn the different commands and steps to install Ruby on Ubuntu 22.04 LTS Jammy JellyFish using the command terminal.

Ruby is an object-oriented, high-level interpreted programming language that is easy to use and productive to use. Inventor Yukihiro Matsumoto wanted to develop a language in which functional and imperative programming are balanced, therefore, this dynamic, free and object-oriented Ruby programming language enjoys great popularity among programmers.

Everything in Ruby is an object that allows any programmer to customize the language to their preferences. Unlike others, the syntax is easier to read and write. It is similar to C and Java, so both Java and C programmers can easily learn Ruby.

Extensive Documents online introduces newcomers to ruby ​​syntax. Many Ruby projects can be found in RubyForge, where you can also find new libraries.

It offers a powerful package manager to distribute Ruby programs and libraries, in a self-contained format called “gem”, as well as tools to easily manage the installation of gems on a server. Ruby programmers also have access to the powerful features of RubyGems.

Ruby supports all major platforms such as Windows, Mac, and Linux.

Steps to Install Ruby on Ubuntu 22.04 LTS

There are three easy ways to install Ruby on Ubuntu Linux here we show them all. Also, the steps given here can be used for other Ubuntu versions such as 20.04/18.04, including other Linuxes – Mint, Debian, Elementary OS, MX Linux, POP_OS, etc.

#1st method using standard Ubuntu repository

1. Run System Update

Let’s first run the system update command which will notify our system’s package manager of the latest packages available through the system repositories.

sudo apt update

2. Install Ruby on Ubuntu 22.04

Yes, we can install Ruby programming language using Ubuntu default repository, however, the version of it will not be the latest one instead of well stable and tested as Ubuntu 22.04 is a taken release long-term support. Therefore, if you want to get the Ruby without adding any additional repository, use the given command:

sudo apt install ruby-full

Once the installation is complete, we can check the version using:

ruby --version

#2nd method using Rbenv

3. Install Rbenv

Rbenv is a command-line tool that allows us to manage multiple versions of Ruby and switch between them. We can also use it to install the latest versions of Ruby using the ruby-build plugin.

Install the required dependencies:

sudo apt install git curl autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev

Obtain the Rbenv installation script:

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

Add a directory path containing the Rbenv files to your system path to use its command line tool:

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

To check the installed version:

rbenv -v

4. Install Ruby using Rbenv

Now Rbenv is ready to use on your Ubuntu 22.04 system, we can use it to list and install any latest version of Ruby on our system.

For listing available versions to install we can use:

rbenv install -l

rbenv install l

To install any of the listed versions, we can use the syntax shown:

rbenv install  version

Replace the “version” in the syntax above with the one you want to install. For example, if you want to install 3.1.2 then the command will be:

rbenv install 3.1.2

How to set the default system-wide version of Ruby:

As we know, we can use rbenv to install and manage multiple versions of Ruby. Therefore, if you have more than two versions on your system and you want to set one of them as your system’s default version, the syntax is:

rbenv global version

Replace the “version” with whatever you want to set as the system-wide default.

For example:

rbenv global 3.1.2

To remove any version of ruby:

rbenv uninstall version

#3rd method using Install Ruby using RVM- Ruby Version Manager

5. Install RVM – Ruby Version Manager

Another way to install Ruby on our Ubuntu 22.04 is to use another command line tool called RVM– Ruby version manager.

Ruby Version Manager abbreviated as RVM, is a software platform developed to manage multiple installations of Ruby on the same device which includes the entire ruby ​​environment including the Ruby interpreter and installed RubyGems. This helps developers easily switch between different versions of Ruby according to the requirements of different projects.

Install dependencies:

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

Install the GPG key

gpg --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Get RVM:

curl -sSL https://get.rvm.io | bash -s stable

After this source, the variables:

source ~/.rvm/scripts/rvm

6. Get Ruby language on Ubuntu 22.04

Finally, we can use RVM to install the available Ruby versions, to list them we can use the given command:

rvm list known

RVM lists Ruby versions

To install a specific version listed after running the previous command, you can use:

rvm install ruby-version

Replace “version” in the command above with the one you want to install, for example, say you want to have 3.1.2

rvm install ruby-3.1.2

While to simply install the latest version available, use:

rvm install ruby

How to use RVM to set a specific version of Ruby as the system default;

rvm --default use ruby-version

Replace “version” in the command above with the one you want to install

To remove any version of ruby:

rvm remove ruby-version

7. Uninstall or remove

Depending on the method you used to install Ruby, you can remove the same using the given commands:

To remove APT installed Ruby

sudo apt remove ruby-full

To remove Rbenv

rm -rf ~/.rbenv

To remove RVM

rvm implode
rm -rf ~/.rvm
rm -rf /etc/rvmrc
rm -rf ~/.rvmrc

Other Items:

• How to Install Maven on Ubuntu 22.04 LTS Jammy
• How to install CUDA on Ubuntu 20.04 LTS…
• Accessing Ubuntu 22.04 Remote Desktop from Windows…
• 4 Ways to Install Firefox Browser on Ubuntu 22.04…

Related posts:

  1. Goa, 13-year-old boy, manages millions of dollars in cryptocurrency | Goa News
  2. 4 “exotic” programming languages ​​popular with malware developers
  3. Intimidated by Kafka? Discover the new Confluent developer site
  4. 5 Best Java Development Companies in Vietnam

Archives

  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • January 2021
  • December 2019
  • November 2019
  • October 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2017

Categories

  • C++ programming
  • Java programming
  • Php programming
  • Phyton programming
  • Programming industry

Recent Posts

  • 12-bit dual-channel PCIe card samples at 2x 3.2 Gsample/s
  • Woster: Need work for those stifled by student loans – Mitchell Republic
  • How to Become a Cloud Engineer
  • [Unveil]Emerging indie band SURL wants to bring rock back to the masses
  • Ansible vs. Puppet | Compare DevOps tools
  • Privacy Policy
  • Terms and Conditions