Getting and Installing Ruby
No matter how wonderful Ruby is, there isn't much you can do with it if it is not installed on your computer system. In this chapter we will cover the download and installation of Ruby on a variety of different operating systems, specifically Linux, UNIX, Windows and Mac OS X.
Ruby is itself written in the C programming language. This means that either a binary distribution for your chosen operating system and hardware platfrom needs to be installed, or the Ruby sources need to be downloaded and compiled on your target system. Whilst compiling Ruby yourself might be fun, it usually makes more sense to simply download and install one of the many pre-built Ruby packages rather than attempt to build your own. In this chapter we will cover installing pre-built Ruby packages on each platform.
Installing Ruby on Linux
There are a number of different Linux distributions available today and it makes sense to install the Ruby package built specifically for your chosen Linux flavor. The best way to do this is to use the standard package manager for that particalur Linux.
Red Hat Enterprise and Fedora Linux
Red Hat Enterprise Linux and Fedora Linux both use the YUM installation manager and rpm. The first step is to verify if Ruby is installed. This can be achieved using the following rpm command. In this example, Ruby is not yet installed:
rpm -q ruby package ruby is not installed
If Ruby is not installed, it can be installed using the yum update manager. This needs to be performed as root so the superuser password will be required in the following steps:
su - yum install ruby
The yum tool will locate the ruby package and any other packages on which Ruby is dependent and prompt you to install the packages:
Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: ruby i386 1.8.1-7.EL4.8 base 156 k Installing for dependencies: ruby-libs i386 1.8.1-7.EL4.8 base 1.5 M Transaction Summary ============================================================================= Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 1.6 M Is this ok [y/N]:
Enter 'y' to download and install the required packages:
Downloading Packages: (1/2): ruby-1.8.1-7.EL4.8 100% |=========================| 156 kB 00:10 (2/2): ruby-libs-1.8.1-7. 100% |=========================| 1.5 MB 01:23 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: ruby-libs ######################### [1/2] Installing: ruby ######################### [2/2] Installed: ruby.i386 0:1.8.1-7.EL4.8 Dependency Installed: ruby-libs.i386 0:1.8.1-7.EL4.8 Complete!
Once the installation is complete, you may re-run the rpm command to verify the package is now installed:
rpm -q ruby ruby-1.8.1-7.EL4.8