Last modified on 24 July 2014, at 14:43

Ruby Programming/Installing Ruby

← Overview | Ruby editors →Ruby comes preinstalled on Mac OS X and many Linux distributions. In addition, it is available for most other operating systems, including Microsoft Windows.

To find the easiest way to install Ruby for your system, follow the directions below. You can also install Ruby by compiling the source code, which can be downloaded from the Ruby web site.

Operating systemsEdit

Mac OS XEdit

Ruby comes preinstalled on Mac OS X. To check what version is on your system:

  1. Launch the Terminal application, which is located in the "Utilities" folder, under "Applications".
  2. At the command-line, enter: ruby -v

If you want to install a more recent version of Ruby, you can:

  • Buy the latest version of Mac OS X, which may have a more recent version of Ruby.
  • Install Ruby using RVM. (This is the most popular way because you can manage ruby versions and install many other ruby packages)
  • Install Ruby using Fink.
  • Install Ruby using MacPorts.
  • Install Ruby using Homebrew.


Ruby comes preinstalled on many Linux systems. To check if Ruby is installed on your system, from the shell run: ruby -v

If ruby is not installed, or if you want to upgrade to the latest version, you can usually install Ruby from your distribution's software repository. Directions for some distributions are described below.

Debian / UbuntuEdit

On Debian and Ubuntu, install Ruby using either the graphical tool Synaptic (on Debian, only if it is installed; it is included with Ubuntu) or the command-line tool apt.

Fedora CoreEdit

If you have Fedora Core 5 or later, you can install Ruby using the graphical tool Pirut.[1] Otherwise, you can install Ruby using the command-line tool yum.

Arch LinuxEdit

If you have Arch Linux you can install Ruby using the command-line tool pacman.

Mandriva LinuxEdit

On Mandriva Linux, install Ruby using the command-line tool urpmi.


On PCLinuxOS, install Ruby using either the graphical tool Synaptic or the command-line tool apt.

Red Hat LinuxEdit

On Red Hat Linux, install Ruby using the command-line tool RPM.


Ruby does not come preinstalled with any version of Microsoft Windows. However, there are several ways to install Ruby on Windows.

  • Download and install one of the compiled Ruby binaries from the Ruby web site.
  • Download and run the one click RubyInstaller.
  • Install Cygwin, a collection of free software tools available for Windows. During the install, make sure that you select the "ruby" package, located in the "Devel, Interpreters" category.

Windows is slowEdit

Currently Ruby on windows is a bit slow. Ruby isn't optimized for windows, because most core developers use Linux. Though 1.9.2 passes almost all core tests on windows.

Most of today's slowdown is because when ruby does a

require 'xxx'

it searches over its entire load path, looking for a file named xxx, or named xxx.rb, or or what not. In windows, doing file stat's like that are expensive, so requires take a longer time in windows than linux. 1.9 further complicates the slowdown problem by introducing gem_prelude, which avoids loading full rubygems (a nice speedup actually), but makes the load path larger, so doing require's on windows now takes forever. To avoid this in 1.9.2, you can do a

require 'rubygems'

which reverts to typical load behavior.

If you want to speed it up (including rails) you can use

Which have some work arounds to make loading faster by caching file locations.

Also the "rubyinstaller" (mingw) builds are faster than the old "one click" installers If yours comes from, chances are you are good there.

NB that Jruby tends to run faster but start slower, on windows, than its MRI cousins. Rubinius is currently not yet windows compatible.

Building from SourceEdit

If your distro doesn't come with a ruby package or you want to build a specific version of ruby from scratch, please install it by following the directions here. Download from here.

Compile optionsEdit

Building with debug symbolsEdit

If you want to install it with debug symbols built in (and are using gcc--so either Linux, cygwin, or mingw).

 ./configure --enable-shared optflags="-O0" debugflags="-g3 -ggdb"


Note that with 1.9 you can pass it --disable-install-doc to have it build faster.

To set the GC to not run as frequently (which tends to provide a faster experience for larger programs, like rdoc and rails), precede your build with

 $ export CCFLAGS=-DGC_MALLOC_LIMIT=80000000

though you might be able to alternately put those in as opt or debug flags, as well.

Testing InstallationEdit

The installation can be tested easily.

$ ruby -v

This should return something like the following:

ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]

If this shows up, then you have successfully installed Ruby. However, if you get something like the following:

-bash: ruby: command not found

Then you did not successfully install Ruby.


  1. "yum". Fedora Wiki. Retrieved 2006-09-13.