w3resource logo


Ruby tutorials

Ruby Installation

Secondary Nav

Introduction

There are several tools to install Ruby in different operating systems. Here we have discussed how to use major package management systems and third-party tools for managing and installing Ruby and how to build Ruby from source.

You can use the following installation method to install Ruby :

  • For a UNIX-like operating system, system package manager is the easiest way to install.
  • For specific or multiple Ruby versions an installer can be used.
  • Build Ruby from source.

The following overview lists available installation methods for different needs and platforms.

  • Package Management Systems
    • Debian, Ubuntu
    • CentOS, Fedora, RHEL
    • Gentoo
    • Arch Linux
    • OS X
    • Solaris, OpenIndiana
    • Other Distributions
  • Installers
    • ruby-build
    • ruby-install
    • RubyInstaller (Windows)
    • RailsInstaller and Ruby Stack
  • Building from source

Package Management Systems

You can use your system’s package manager to install Ruby without using a third-party tool or compile your own Ruby.

apt (Debian or Ubuntu) :

apt package manager is used to installing Ruby on Debian GNU/Linux and Ubuntu. You can use the following command :

$ sudo apt-get install ruby-full

yum (CentOS, Fedora, or RHEL) :

yum package manager is used to installing Ruby on CentOS, Fedora and RHE. You can use the following command :

$ sudo yum install ruby

portage (Gentoo) :

portage package manager is used to install Ruby on Gentoo. You can use the following command :

$ sudo emerge dev-lang/ruby

pacman (Arch Linux) :

pacman package manager is used to install Ruby on Arch Linux. You can use the following command :

$ sudo pacman -S ruby

Homebrew (OS X.) :

Homebrew package manager is used to install Ruby on OS X Yosemite and Mavericks, Ruby 2.0 is included. OS X Mountain Lion, Lion, and Snow Leopard ship with Ruby 1.8.7. You can use the following command :

$ brew install ruby

Ruby on Solaris and OpenIndiana :

Ruby 1.8.7 is available for Solaris 8 through Solaris 10 on Sunfreeware and Ruby 1.8.7 is available at Blastwave. Ruby 1.9.2p0 is also available at Sunfreeware, but this is outdated. You can use the following command :

$ pkg install runtime/ruby-18

Note : The third-party tools might be a good way to obtain the latest version of Ruby.

Installers

To install a newer version of Ruby on an existing older version you can use a third-party installer. Some installer allows you to install multiple version on the same system where associated managers can help to switch between the different Rubies. If you use RVM as a version manager you do not need a separate installer, it comes with its own.

ruby-build :
ruby-build is a plugin for rbenv that allows you to compile and install different versions of Ruby into arbitrary directories. ruby-build can also be used as a standalone program without rbenv. It is available for OS X, Linux, and other UNIX-like operating systems.

ruby-install :
ruby-install allows you to compile and install different versions of Ruby into arbitrary directories. There is also a sibling, chruby, which handles switching between Ruby versions. It is available for OS X, Linux, and other UNIX-like operating systems.

RubyInstaller :
If you are on Windows, there is a great project to help you install Ruby: RubyInstaller. It gives you everything you need to set up a full Ruby development environment on Windows

Building from Source

You can install Ruby from source. Download and unpack a tarball, then execute the following commands :

$ ./configure
$ make
$ sudo make install

The above will install Ruby into /usr/local.
To change, pass the --prefix=DIR option to the ./configure script.



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number