How to Install Ruby on Debian 10
Ruby is one of the most famous dialects today. It has an exquisite grammar, and it is the language behind the Ruby on Rails structure.
In this article, we will look into different ways to install Ruby on Debian 10.
We’ll tell the best way to introduce Ruby from the default Debian 10 storehouses and utilizing the Rbenv and RVM contents. Pick the establishment strategy that is generally fitting for your arrangement and condition.
Install Ruby from Debian Repositories #
This is the least demanding strategy for introducing Ruby on Debian. At the hour of composing, the rendition in the standard Debian storehouses is 2.5.5.
Run the following commands as root or user with sudo privileges to refresh the packages list and install Ruby:
sudo apt update
sudo apt install ruby-full
Once the installation is completed, verify it by printing the Ruby version:
The output will look something like this:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
Your Ruby version may differ from the one shown above.
That’s it! You have successfully installed Ruby on your CentOS system, and you can start using it.
Installing Ruby using Rbenv #
Rbenv is a lightweight Ruby form the board utility that permits you to effortlessly switch Ruby variants.
We’ll use the
ruby-build plugin that extends the core functionality of Rbenv and allow you to install any Ruby version from source.
Start by introducing git and different conditions required to fabricate Ruby from the 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
Run the following command to install both rbenv and ruby-build scripts:
curl -sL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash -
To start using
rbenv, you need to add
$HOME/.rbenv/bin to your
If you are using Bash:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
If you are using Zsh:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
rbenv -v command to ensure that installation was successful:
To get a list of all Ruby versions that can be installed with
rbenv install -l
For example, to install Ruby version 2.7.0 and set it as default version, you would type:
rbenv install 2.7.0
rbenv global 2.7.0
Verify that Ruby was properly installed:
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
Install Ruby using RVM #
RVM (Ruby Version Manager) is an order line device that permits you to introduce, oversee, and work with various Ruby situations.
Install the dependencies required to build 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
Run the following commands to add the GPG key and install RVM:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
To start using RVM, enter:
To get a list of all known Ruby versions type:
rvm list known
Install the latest stable version of Ruby with RVM and set it as the default version:
rvm install ruby
rvm --default use ruby
Verify that Ruby was properly installed by printing the version number:
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
If you want to install a specific version of Ruby, enter the commands below. Replace
x.x.x with the Ruby version you want to install:
rvm install ruby-x.x.x
rvm --default use ruby-x.x.x
For more information about how to manage your Ruby installations with RVM check their Documentation page.
We have given you three unique approaches to introduce Ruby on your Debian 10 server. The strategy you pick relies upon your prerequisites and inclinations. Despite the fact that introducing the bundled form from the Debian storehouse is simpler, the Rbenv and RVM techniques give you greater adaptability for including and expelling diverse Ruby forms on a for every client premise.
If you have any questions or feedback, feel free to comment below.