# (this may take a while - installing RDoc documentation can be CPU/RAM intensive)

+

Running "gem update" doesn't replace your old gems with newer versions; it installs the newer version alongside the older, previously installed version. This is a feature intended to maintain compatibility with older applications that rely on older gems, while allowing new development using the newer versions. An application can specify which version of a gem to use. If an application does not specify a version, the latest version will be used.

Installing Ruby on Raspberry Pi

This is a guide to install Ruby on the Raspberry Pi computer running Debian "squeeze".

There are multiple ways to install Ruby, each with their own pros and cons. The guide provides step-by-step instructions for two methods, and points to another page which contains a third method. All methods require an Internet connection.

The guide has been developed/tested using debian6-19-04-2012. Depending on how you choose to install Ruby, there may not be enough room on a standard 2Gb image. This is especially true if you've already installed anything else. Learn how to expand your image here or here.

Installing Ruby From The Debian Repository

Pros

Very easy

Supported by the Debian team.

Uses only 10MB of hard drive space

Does not install RubyGems or any gem add-ons (optional tools/features that you may not need)

Cons

Installs Ruby v1.8.7p302, an older version of Ruby 1.8.7 (current release in the 1.8.7 family is Ruby v1.8.7p358)

Does not install RubyGems or any gem add-ons (optional tools/features that you may need and will have to install yourself)

Commands

Installing Ruby from the Debian repository is fantastically simple:

# Install Ruby from the Debian repository
sudo apt-get install ruby

Done!

Installing Ruby From The Source Code

You can also install Ruby by downloading and compiling the source code. You can download the source code from the official Ruby FTP server.

Pros

You can install a specific release/version of Ruby

Access to newer releases/versions than what's in the Debian repository

Might install RubyGems and some gem add-ons (optional tools/features that you may need)

Cons

Compiling can be a tricky business, and compiler options may change between releases or versions

Little-to-no help for beginners if something goes wrong during compilation or installation

You are responsible for patching/upgrading to releases/versions that are more stable and/or more secure; can't rely on the Debian repository!

Could require 250MB (or more!) free space during the installation process. That's nearly all the available space on the standard 2GB image.

Might install RubyGems and some gem add-ons (optional tools/features that you may not need)

Releases

There are two main releases of Ruby: v1.8.7, and v1.9.x. Discussion of the differences between these releases is beyond the scope of this guide. In a nutshell: The core Ruby language has not significantly changed between releases, but v1.9.x includes a variety of optimizations and a few popular gems (optional tools/features that are utilized by a number of Ruby programmers).

Ruby v1.8.7

Ruby v1.8.7 is still actively maintained by the Ruby community, although it is no longer being actively developed. Put another way, it gets bug fixes, but no new features.
Ruby v1.8.7 is regularly used for older Ruby on Rails applications.

Pros

Only requires 30MB free space during installation

Uses 15MB of hard drive space

Does not install RubyGems or any gem add-ons (optional tools/features that you may not need)

Cons

Older release (but still supported)

Does not install RubyGems or any gem add-ons (optional tools/features that you may need and will have to install yourself)

Commands

Compiling Ruby from the source code requires that a few other development packages are already installed.

You can download the source code from the official Ruby FTP server. The following instructions use Ruby v1.8.7p358, the most recent 1.8.7 version at the time of this writing. If the following "wget" command fails to download anything, then the Ruby team has likely released a newer version of Ruby v1.8.7 - you'll have to check their site and change these instructions accordingly.

Ruby v1.9.x

Ruby v1.9.x is actively maintained and developed by the Ruby community. It gets both bug fixes and new features/optimizations.
Ruby v1.9.x is regularly used for new Ruby on Rails applications.

Pros

Newest release of Ruby

Uses 15MB of hard drive space, even with the additional tools that don't come with the other releases

Installs RubyGems and some popular gem add-ons (optional tools/features that you may need)

Cons

Requires 250MB of free space during installation - this is nearly all the available space on the standard 2GB image.

Installs RubyGems and some popular gem add-ons (optional tools/features that you may not need)

Commands

These instructions have been measured almost to the megabyte - the amount of available space on a standard 2GB image dips down into low single-digits during these instructions. If you have installed anything, including system updates, there is an excellent chance that you will run out of available drive space and this process will fail. And if the root drive is full, the OS may stop functioning and become unbootable, requiring a re-imaging of your boot SD card. You have been warned!

Compiling Ruby from the source code requires that a few other development packages are already installed.

You can download the source code from the official Ruby FTP server. The following instructions use Ruby v1.9-stable. While this makes downloading the latest version easy (it is always named the same), the unzipped, untarballed folder will have a different name. For me, the file "ruby-1.9-stable" contained the folder "ruby-1.9.3-p194". You will likely have to alter these instructions based on the version that is included in Ruby v1.9-stable.

Check out the official Ruby language documentation

Ruby 1.8.7

Ruby 1.9.3

Write and run a simple program

irb
p "Hello World!"
exit

Install RubyGems

(If not already installed - RubyGems is included in some Ruby distributions)

You can optionally install RubyGems , a package manager for Ruby plugins. It is a popular tool among the Ruby development community. These instructions install the most current version of RubyGems available as of this writing.

# Install a new gem ("acts_as_list" is the name of a gem)
sudo gem install acts_as_list
# Remove a gem ("acts_as_list" is the name of a gem)
sudo gem uninstall acts_as_list

Occasionally, you might want to install a specific version of a gem. Assuming you know the version that you want to install:

# Install a specific version of a gem ("acts_as_list" is the name of a gem)
sudo gem install acts_as_list --version 0.1.5

This command will update all of your gems:

# Update all installed gems to the latest versions
sudo gem update
# (this may take a while - installing RDoc documentation can be CPU/RAM intensive)

Running "gem update" doesn't replace your old gems with newer versions; it installs the newer version alongside the older, previously installed version. This is a feature intended to maintain compatibility with older applications that rely on older gems, while allowing new development using the newer versions. An application can specify which version of a gem to use. If an application does not specify a version, the latest version will be used.