Ruby is a popular, open-source programming language known for its simplicity, flexibility, and focus on developer productivity. It is commonly used for web development, system administration, and many other applications. In this tutorial, we will show you how to install Ruby on Arch Linux using different methods, including the default package manager pacman
, the version manager rbenv
, and the popular version management tool RVM
.
Table of Contents
- Prerequisites
- Installing Ruby using pacman
- Installing Ruby using rbenv
- Installing Ruby using RVM
- Verifying Ruby installation
- Conclusion
Prerequisites
Before you begin, make sure you have the following:
- A system running Arch Linux
- A user account with
sudo
privileges - An active internet connection
How to Install Ruby on Arch Linux
Installing Ruby using pacman
Installing Ruby using the default package manager pacman
is the simplest method. It installs the latest stable version of Ruby available in the Arch Linux repository. Follow these steps to install Ruby using pacman
:
- Update your system packages:
sudo pacman -Syu
Install Ruby:
sudo pacman -S ruby
Wait for the installation to complete.
Installing Ruby using rbenv on Arch Linux
rbenv is a lightweight Ruby version management tool that allows you to install and switch between multiple Ruby versions easily. Follow these steps to install Ruby using rbenv
:
- Install the required dependencies:csharp
sudo pacman -S git base-devel openssl zlib
Clone the rbenv
repository:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Add rbenv
to your PATH:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Install the ruby-build
plugin:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Install the desired version of Ruby (replace {version}
with the desired Ruby version, e.g., 3.1.0
):
rbenv install {version}
Set the installed Ruby version as the default:
rbenv global {version}
Installing Ruby using RVM on Arch Linux
RVM (Ruby Version Manager) is another popular tool for managing multiple Ruby versions. Follow these steps to install Ruby using RVM:
- Install the required dependencies:
sudo pacman -S curl gnupg
Import the RVM GPG key:
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Install RVM:
curl -sSL https://get.rvm.io | bash -s stable
Load RVM:
source ~/.rvm/scripts/rvm
Install the desired version of Ruby (replace {version}
with the desired Ruby version, e.g., 3.1.0
):
rvm
rbenv install {version}
After the installation is complete, set the desired version as the default Ruby version for your user account:
rbenv global {version}
Verify that the desired Ruby version is set as the default by running:
ruby -v
You should see the version number you just installed displayed in the terminal.
Keep your Ruby installation up-to-date
To keep your Ruby installation up-to-date, periodically update the rbenv
and ruby-build
plugins by running the following commands:
cd ~/.rbenv/plugins/rbenv && git pull
cd ~/.rbenv/plugins/ruby-build && git pull
When new Ruby versions are released, you can easily install them using the rbenv install
command and update the default version with rbenv global
.
Install Ruby Gems on Arch Linux
Ruby Gems are packages that extend the functionality of Ruby. To manage your Ruby Gems, you can use the built-in gem
command.
To install a new Ruby Gem, run:
gem install {gem-name}
Replace {gem-name}
with the name of the Ruby Gem you want to install.
Some popular Ruby Gems include:
- Rails: A web application framework for Ruby.
- Sinatra: A lightweight web application framework for Ruby.
- Jekyll: A static site generator for Ruby.
For example, to install Rails, run:
gem install rails
You can also update your installed Ruby Gems by running:
gem update
Conclusion
You have now successfully installed Ruby on your Arch Linux system! By following this guide, you can easily manage multiple Ruby versions and keep your Ruby installation up-to-date with the rbenv
tool.
Be sure to check out some of our other helpful tutorials for Arch Linux, such as How to Install Wget on Arch Linux, How to Install Vim on Arch Linux, and How to Install Git on Arch Linux. Additionally, if you’re looking to further enhance your web development skills, explore our guide on How to Set Up an Apache Web Server on Arch Linux.