How is homebrew cared for?

Ruby

There are several ways to install Ruby. This page describes how to use the most important package management systems and third-party tools to install and manage Ruby, as well as how to compile it from the source code.

Installation methods

The following overview shows the available installation methods for the most common platforms.

Third party tools

Many Rubyists use third-party tools to install Ruby. They offer several advantages, but are not officially supported. Nonetheless, their respective communities are very helpful.

rbenv

rbenv allows the administration of multiple Ruby installations. It doesn't support installing Ruby itself, but there is a popular plug-in called ruby-build. Both tools are available for macOS, Linux or other UNIX-like operating systems.

See the rbenv website for the latest information on installing rbenv.

A similar tool is RVM, see the next section.

RVM ("Ruby Version Manager")

RVM allows multiple Ruby installations to be installed and managed on one system. It is available for macOS, Linux, or other UNIX-like operating systems.

The most up-to-date installation instructions for RVM can be found on the RVM installation page.

RubyInstaller

For Windows users, the installation with the help of the RubyInstaller has become established, which brings all the necessary tools for Ruby development under Windows.

To use RubyInstaller, all you have to do is download it from the RubyInstaller download page and start it. Finished!

RailsInstaller and Ruby Stack

There are special installers for using Ruby on Rails:

  • RailsInstaller builds on the RubyInstaller, but contains a few other tools that simplify development with Rails. OS X and Windows are supported.
  • Bitnami Ruby Stack provides a complete development environment for Rails. MacOS, Linux, Windows, virtual machines and cloud images are supported.

Package management systems

If you cannot compile Ruby and do not want to use a third-party tool, Ruby can also be installed with the package management system of your operating system.

Some members of the Ruby community strongly argue that Ruby should never be installed using a package management system, but rather use third-party tools. A full discussion of the pros and cons is beyond the scope of this overview, the most important reason being that most package managers have older versions of Ruby in their repositories. To get the latest version, make sure you use the correct package name, or use one of the tools mentioned above instead.

The following package management systems are described in more detail below:

apt (Debian or Ubuntu)

Under Debian or Ubuntu apt is used as package manager, Ruby can be installed with it as follows:

This will install Ruby 2.3.1, an older stable version, on Ubuntu or Debian (as of the writing of this article).

yum (CentOS, Fedora, or RHEL)

CentOS, Fedora and RHEL use yum for package management. Ruby is installed as follows:

The installed version is typically the latest Ruby version that was available at the time the respective distribution was released.

portage (Gentoo)

Gentoo uses portage for package management.

By default, it will install all available versions (1.8, 1.9, and 2.0). Set in your file to install a specific version. See the Gentoo Ruby Project website for details.

pacman (Arch Linux)

On Arch Linux, Ruby can be installed using pacman as follows:

Homebrew (macOS)

OS X Mavericks comes with Ruby 2.0 preinstalled. OS X Mountain Lion, Lion and Snow Leopard ship with Ruby 1.8.7.

There are several options for installing the latest version of Ruby. Most OS X users in the Ruby community use third-party tools for installation, but there are also some package management systems that support Ruby.

Many users use homebrew as a package manager under macOS. Ruby is installed as follows:

Since macOS is based on UNIX, the installation from the source code is just as easy and effective as the other options. Using third-party tools will help install new versions of Ruby.

Ruby on Solaris and OpenIndiana

Ruby 1.8.7 is available for Solaris 8 through Solaris 10 under Sunfreeware, and Ruby 1.8.7 is available from Blastwave. Ruby 1.9.2-p0 can also be found on Sunfreeware, but this version is out of date. The latest version can be installed using third-party tools.

To install Ruby under OpenIndiana, you should use the Image Packaging System (IPS). This will install the latest Ruby binaries (1.9) and RubyGems directly from the OpenSolaris repository:

Of course, you can also use third-party tools here.

Other distributions

On other distributions, a search in the package sources of the respective package management system should help; alternatively, third-party tools could be the method of choice.

Compilation from source code

Of course, Ruby can also be compiled from the source code. You can find tarballs on the download page. After unpacking Ruby can be compiled as follows:

By default, Ruby is installed after. This can be changed with the option for the script.

However, third-party tools or package management systems might be a better choice, as the version of Ruby installed in this way is not managed by a tool.