How do I install Ruby on Ubuntu?
With package managers or third-party tools, you have plenty of options to install and manage Ruby. Show
You may already have Ruby installed on your computer. You can check inside a terminal emulator by typing:
This should output some information on the installed Ruby version. Choose Your Installation MethodThere are several ways to install Ruby:
On Windows 10, you can also use the Windows Subsystem for Linux to install one of the supported Linux distributions and use any of the installation methods available on that system. Here are available installation methods:
Package Management SystemsIf you cannot compile your own Ruby, and you do not want to use a third-party tool, you can use your system’s package manager to install Ruby. Some members of the Ruby community feel that you should avoid package managers to install Ruby and that you should use dedicated tools instead. It is possible that major package managers will install older Ruby versions instead of the latest release. To use the latest Ruby release, check that the package name matches its version number. Or use a dedicated installer. apt (Debian or Ubuntu)Debian GNU/Linux and Ubuntu use the apt package manager. You can use it like this:
yum (CentOS, Fedora, or RHEL)CentOS, Fedora, and RHEL use the yum package manager. You can use it like this:
The installed version is typically the latest version of Ruby available at the release time of the specific distribution version. snap (Ubuntu or other Linux distributions)Snap is a package manager developed by Canonical. It is available out-of-the-box on Ubuntu, but snap also works on many other Linux distributions. You can use it like this:
We have several channels per Ruby minor series. For instance, the following commands switch to Ruby 2.3:
portage (Gentoo)Gentoo uses the portage package manager.
To install a specific version, set pacman (Arch Linux)Arch Linux uses a package manager named pacman. To get Ruby, just do this:
This should install the latest stable Ruby version. Homebrew (macOS)Ruby versions 2.0 and above are included by default in macOS releases since at least El Capitan (10.11). Homebrew is a commonly used package manager on macOS. Installing Ruby using Homebrew is easy:
This should install the latest Ruby version. FreeBSDFreeBSD offers both pre-packaged and source-based methods to install Ruby. Prebuilt packages can be installed via the pkg tool:
A source-based method can be used to install Ruby using the Ports Collection. This is useful if you want to customize the build configuration options. More information about Ruby and its surrounding ecosystem on FreeBSD can be found on the FreeBSD Ruby Project website. OpenBSDOpenBSD as well as its distribution adJ has packages for the three major versions of Ruby. The following command allows you to see the available versions and to install one:
You can install multiple major versions side by side, because their binaries
have different names (e.g. The Ruby on OpenIndianaTo install Ruby on OpenIndiana, please use the Image Packaging System (IPS) client. This will install the Ruby binaries and RubyGems directly from the OpenIndiana repositories. It’s easy:
However, the third-party tools might be a good way to obtain the latest version of Ruby. Windows Package ManagerOn Windows, you can use the Windows Package Manager CLI to install Ruby:
Chocolatey package manager for WindowsAlso on Windows, you can use the Chocolatey Package Manager to install Ruby:
It will reuse existing Other DistributionsOn other systems, you can search the package repository of your Linux distribution’s manager for Ruby. Alternatively, you can use a third-party installer. InstallersIf the version of Ruby provided by your system or package manager is out of date, a newer one can be installed using a third-party installer. Some installers allow you to install multiple versions on the same system; associated managers can help to switch between the different Rubies. If you are planning to use RVM as a version manager you don’t need a separate installer, it comes with its own. ruby-buildruby-build is a plugin for rbenv that allows you to compile and install different versions of Ruby. ruby-build can also be used as a standalone program without rbenv. It is available for macOS, Linux, and other UNIX-like operating systems. ruby-installruby-install allows you to compile and install different versions of Ruby into arbitrary directories. chruby is a complimentary tool used to switch between Ruby versions. It is available for macOS, Linux, and other UNIX-like operating systems. RubyInstallerOn Windows, RubyInstaller gives you everything you need to set up a full Ruby development environment. Just download it, run it, and you are done! Ruby StackIf you are installing Ruby in order to use Ruby on Rails, you can use the following installer:
ManagersMany Rubyists use Ruby managers to manage multiple Rubies. They allow easy or even automatic switching between Ruby versions depending on the project and other advantages but are not officially supported. You can however find support within their respective communities. asdf-vmasdf-vm is an extendable version manager that can manage multiple language runtime versions on a per-project basis. You will need the asdf-ruby plugin (which in turn uses ruby-build) to install Ruby. chrubychruby allows you to switch between multiple Rubies. It can manage Rubies installed by ruby-install or even built from source. rbenvrbenv allows you to manage multiple installations of Ruby. While it can’t install Ruby by default, its ruby-build plugin can. Both tools are available for macOS, Linux, or other UNIX-like operating systems. RVM (“Ruby Version Manager”)RVM allows you to install and manage multiple installations of Ruby on your system. It can also manage different gemsets. It is available for macOS, Linux, or other UNIX-like operating systems. uruUru is a lightweight, multi-platform command line tool that helps you to use multiple Rubies on macOS, Linux, or Windows systems. Building from SourceOf course, you can install Ruby from source. Download and unpack a tarball, then just do this:
By default, this will install Ruby into You can find more information about building from source in the Ruby README file. Using the third-party tools or package managers might be a better idea, though, because the installed Ruby won’t be managed by any tools. How do I start Ruby on Ubuntu?Installing Ruby from Ubuntu Repositories
The easiest way to install Ruby on Ubuntu is by using the apt package manager. At the time of writing, the version in the Ubuntu repositories is 2.7. 0 , which may not always be the latest stable release. Your Ruby version may differ from the one shown above.
How do I know if Ruby is installed Ubuntu?For an Ubuntu-based distribution, follow the following procedure to verify whether you have Ruby installed, and if not, to install it.. Open a terminal window. ... . Run the command which ruby. ... . To verify that you have a current version of Ruby, run the command ruby -v.. Does Ruby come with Ubuntu?Ubuntu 22.04 repository also includes the Ruby which you can easily install using the following steps. However, it doesn't install the latest version but still it's the easiest method to install Ruby on Ubuntu.
What is the command to install Ruby?To install Ruby from the default Ubuntu repositories, follow these steps:. First, update the packages index: sudo apt update.. Install Ruby by typing: sudo apt install ruby-full.. To verify that the installation it was successful run the following command which will print the Ruby version: ruby --version.. |