• 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 Debian 11 Bullseye

Written by Admin, Updated On January 19, 2023
debian, rails, ruby
How to Install Ruby on Debian 11

Ruby is an open-source framework used to make games, web application as well as behind the ruby-on-rails framework. In this tutorial, described steps to install Ruby on Debian 11.

Prerequisites#

Before you start installation, make sure that you must logged in with non-root user account with sudo privileges.

Installing Ruby from Debian Repositories#

By default, Debian default repository includes Ruby package. So you can install it using apt package manager.

Follow the below steps to install Ruby from the default Debian repositories:

Step 1 – Update Package Index#

At first, you need to update the packages index list:

sudo apt update
sudo apt upgrade

Step 2 – Installing Ruby#

After that, use below command to install ruby:

sudo apt install ruby-full -y

Step 2 – Verify Installation#

You can verify the installation by issuing the below command and it will print the version of installed Ruby.

ruby --version

It should look like as below:

ruby 3.2.0p57 (2022-12-08 revision 63029) [x86_64-linux-gnu]

Install Ruby using Rbenv#

Rbenv is a Ruby version management tool. Using this tool you can easily switch the version of Ruby on same system if installed multiple versions. By default Rbenv doesn’t handle installing Ruby versions so we also need to install ruby-build which is a tool that will help you to install specific version of Ruby which you need.

Perform the below given steps to install Ruby using Rbenv:

Step 1 – Update Package List#

First of all, you should update the package index list by typing:

sudo apt update

Step 2 – Install Dependencies#

After that, we will install dependencies for installation of rbenv and ruby-build:

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

Step 3 – Install Rbenv & Ruby Build#

Next run the following curl command to install rbenv and ruby-build:

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

Above command will clone both rbenv and ruby-build repositories from GitHub to ~/.rbenv directory.

Add $HOME/.rbenv/bin to the system PATH.

If you are using Bash, run:

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

If you are using Zsh run:

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

Step 4 – Set Default Version#

Select the latest and stable version of Ruby and you can set default version as per your need.

rbenv install 3.2.0
rbenv global 3.2.0

Step 5 – Verify Installation#

You can confirm installation by issuing below command:

ruby -v

It should show output as below:

ruby 3.2.0p222 (2022-12-08) [x86_64-linux-gnu]

Ruby Program Example#

We are going to create a simple ruby program. So create a demo.rb file using your favorite editor:

sudo nano demo.rb

Paste below lines in to that file:

puts "Ruby Simple Demo"

Save file and exit from editor using Ctrl+x.

To run demo.rb file issue below command:

ruby demo.rb

It will print simple output as below:

Ruby Simple Demo

Conclusion#

You have successfully learned multiple ways to install Ruby on Debian 11 Bullseye. 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 Composer on Debian 11
Next Article   How to Install PHP 8.2 on Ubuntu 22.04

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install and Use Docker on Debian 11

    How to Install and Use Docker on Debian 11

    March 10, 2023
  • How to Install MariaDB on Debian 11 Bullseye

    How to Install MariaDB on Debian 11 Bullseye

    March 8, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 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