Ruby is a dynamic, open-source programming language known for its clean, readable syntax. It powers the Ruby on Rails web framework and is widely used for web development, scripting, and DevOps automation with tools like Chef, Puppet, and Vagrant.
This guide covers three methods to install Ruby on Ubuntu 18.04. Use the apt method for servers where a single version is enough. Use Rbenv or RVM when you need to switch Ruby versions across different projects.
<strong>Prerequisite:</strong> You need sudo access.
Installing from the Ubuntu repositories requires no extra tools:
bashsudo apt updatesudo apt install ruby-full
The ruby-full package installs the complete Ruby standard library: the interpreter, the interactive shell (irb), the documentation generator (rdoc), and the rake build tool. Installing just the ruby package without the -full suffix gives only the minimal interpreter without these extras.
Verify the installation:
bashruby --version
Ubuntu 18.04 ships Ruby 2.5.1 in its main repositories. This method works well for single-version server deployments where upgrades follow the Ubuntu LTS release cycle.
Rbenv is a lightweight Ruby version manager that works through shims — small wrapper scripts that redirect Ruby commands to the correct installed version. It does not modify shell built-ins or inject shell functions, which makes it easier to uninstall or disable than RVM.
Install the required build dependencies, then run the rbenv installer:
bashsudo apt updatesudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libncurses5-dev libffi-dev libgdbm-devcurl -sL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-installer | bash -
The installer clones both rbenv and ruby-build into ~/.rbenv. The ruby-build plugin is required because rbenv itself does not compile Ruby ruby-build provides the rbenv install command.
Add rbenv to your PATH. For Bash:
bashecho 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrcecho 'eval "$(rbenv init -)"' >> ~/.bashrcsource ~/.bashrc
The eval "$(rbenv init -)" line inserts the shims directory at the front of the PATH and enables shell completion for rbenv commands.
Install Ruby and set it as your global default:
bashrbenv install 2.5.1rbenv global 2.5.1ruby -v
rbenv global sets the default for your entire user account. Use rbenv local 2.5.1 inside a project directory to create a .ruby-version file that pins that project to a different version without changing the global setting. To list all installable versions: rbenv install -l.
RVM (Ruby Version Manager) is a full-featured version manager that adds gemset support — isolated collections of installed gems per project, even within the same Ruby version. This is useful when two projects need conflicting gem versions.
Import the RVM team’s GPG keys and run the installer:
bashgpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDBcurl -sSL https://get.rvm.io | bash -s stablesource ~/.rvm/scripts/rvm
The source command activates RVM in the current session. Add it to ~/.bashrc to load automatically in future shells.
Install Ruby and set it as the default:
bashrvm install 2.5.1rvm use 2.5.1 --defaultruby -v
Which method fits your situation:
All three methods give you a working Ruby installation on Ubuntu 18.04. The right choice depends on how much version flexibility your workflow needs. Leave a comment below if you run into any issues.
Mattermost is an open-source, self-hosted team messaging platform and a direct alternative to Slack. It is…
PyCharm is a full-featured Python IDE developed by JetBrains. It includes built-in debugging, embedded Git control,…
PHP 8.5 is included in Ubuntu 26.04's default repositories and is the recommended version for…
Ubuntu 26.04 LTS "Resolute Raccoon" arrived on April 23, 2026 with Linux kernel 7.0, GNOME 50,…
Kubernetes is the standard platform for running containerized workloads across multiple servers with self-healing, rolling…
Ubuntu 26.04 LTS "Resolute Raccoon" was released on April 23, 2026 with Linux kernel 7.0, GNOME desktop, and standard security support until April 2031. A clean install gives you a known-good starting point on new hardware, when replacing another operating system, or when an upgrade path is not practical. This guide walks through how to install Ubuntu 26.04: downloading and verifying the ISO, writing a bootable USB drive, completing the installer, and doing the initial setup after the first boot. Before you start: You need a USB drive with at least 12 GB of free space. Back up any existing data on the target machine — the installer can erase the entire disk. Install Ubuntu 26.04: Download the ISO…