Ruby Programming/Installing Ruby

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

← 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.

Contents

[edit] Operating systems

[edit] Mac OS X

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 Fink.
  • Install Ruby using MacPorts.

[edit] Linux

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.

[edit] Debian / Ubuntu

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.

[edit] Fedora Core

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.

[edit] Mandriva Linux

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

[edit] PCLinuxOS

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

[edit] Red Hat Linux

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

[edit] Windows

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 One-Click Ruby Installer.
  • 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.

[edit] Testing Installation

The installation can be tested easily.

$ ruby -v

This should return something like the following:

ruby 1.8.5 (2006-08-25) [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.

[edit] References

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