Installing Ruby
Installing Ruby itself is quick and easy, but this page also covers a few additional steps that are needed for an ideal Ruby 1.8 environment:
For details on setting up JRuby, refer to this page.
All of the Linux distributions provide packages for Ruby. To install Ruby on Ubuntu, enter the following command:
sudo apt-get install irb ri ruby rubygems
The Debian and Ubuntu distributions also provide packages of example code:
sudo apt-get install ruby1.8-examples
Once the package is installed, check /usr/share/doc/ruby1.8-examples/ for the example scripts.
Run this command to install a C compiler and the necessary supporting source code:
sudo apt-get install build-essential ruby-dev
Once Ruby is installed, check the version of RubyGems:
gem --version
If the version is less than 1.3, stop and find out the recommended procedure for updating your distribution to use RubyGems 1.3 or higher. Do not attempt to install gems with an outdated version of RubyGems.
Install Gems To Your Home Directory: This ensures that RubyGems installs and updates packages to your home directory, leaving the system copies untouched. See below for more information.
You must also add this line to the .bashrc file in your home directory, so that you can use any command-line utilities that are installed by RubyGems:
export PATH=$PATH:/var/lib/gems/1.8/bin
Where possible, avoid installing gems into the global system. This ensures that the gems that you install are easy to identify and manage, and do not interfere with the global Ruby installation.
As of RubyGems 1.3, RubyGems will automatically install gems into your home directory if the system location is not accessible. You will see that directory called .gem is created within your home directory to store gem files. This means that RubyGems will do the right thing when managing packages, provided that you do not run the gem utility with administrative privileges.
To make this arrangement complete, you need to add the bin subdirectory to your PATH environment variable. This enables you to use any command-line utilities that are installed with your gem packages. To do this on UNIX-like systems, edit the profile file in your home directory (.bashrc on Debian-based Linux), and amend the PATH line to read:
export PATH=$HOME/.gem/ruby/1.8/bin:/var/lib/gems/1.8/bin:$PATH
RubyGems will warn you if the PATH is not set correctly.
To access the documentation for gems in your private home directory with the gem server facility, use the -d option:
gem server -d $HOME/.gem/ruby/1.8
Then point your Web browser to the normal URL:
http://localhost:8808
To install Ruby on Windows, first go to the RubyInstaller project Website. Download both the RubyInstaller and the Development Kit. The Development Kit provides a C compiler. Ignore the One-Click Installer options, as the One-Click Installer has been superseded by the RubyInstaller.
Run the Ruby Installer, and accept the defaults. Follow the instructions to setup the Development Kit.
You need to have an archive utility installed, as Windows does not include support for the 7Zip format used to compress the Development Kit.
To enable your Ruby installation with work with web proxy servers that require Windows authentication (known as NTLM authentication), use rubysspi. This package includes several features to allow RubyGems and Ruby standard libraries to use such proxy servers.
If RubyGems is not able to fetch gem packages at this point, use your Web browser to download the rubysspi gem to your hard drive. Run the gem utility, specifying the full name of the downloaded package file. For example:
gem install rubysspi-1.3.1.gem
To enable RubyGems to work with NTLM proxies, simply install the gem and copy the file spa.rb from the package directory (e.g. C:\Ruby\lib\ruby\gems\1.8\gems\rubysspi-1.3.1) to the Ruby site directory, which is C:\Ruby\lib\ruby\site_ruby\1.8 for Ruby 1.8.
copy C:\Ruby\lib\ruby\gems\1.8\gems\rubysspi-1.3.1\spa.rb C:\Ruby\lib\ruby\site_ruby\1.8
RubyGems will then use remote servers as normal, transparently logging on to the default proxy server for the Windows installation with the credentials of the logged-in user. To set the default proxy server, go to Start > Control Panel > Network and Internet > Internet Options > Connections > LAN Settings.
To use the default Ruby on Rails configuration and other applications that depend upon SQLite, you need to install it separately. Luis Lavena provides full instructions for setting up Rails and SQLite on Windows.
Alternatively, you can use Amalgalite, which provides SQLite as a Ruby library. Install the ActiveRecord adapter for Amalgalite to use Amalgalite with Ruby on Rails.
Current versions of Mac OS X include Ruby, along with Rails and supporting libraries. You need to install the C compiler yourself.
For details on setting Mac OS X for Ruby development, refer to this page.
All original content is © 2010, Stuart Ellis.
This material is provided under the Creative Commons Attribution-Share Alike 3.0 License.