Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:
Ruby 1.9 (Development)
Summary: Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9
- Vastly improved performance over 1.8
- New features for concurrency such as fibers.
- Various other language improvements, such as an improved CSV parser.
- Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)
- Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.
To install Ruby 1.9, simply run:
# pacman -S ruby
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:
# gem update --system
Ruby 1.8.7 (Stable)
Summary: Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.
- Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails
- Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".
Ruby 1.8.6 (Legacy)
Summary: Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.
- Compatible with just about anything
- Missing some performance and language enhancements from 1.8.7
- Support might be dropped with Rails 3.0 (in Beta at the time of writing)
# yaourt -S ruby1.8.6-legacy
RubyGems must be installed seperately using the standard rubygems package:
# yaourt -S rubygems
gem is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The gem command will be installed if you followed the installation instructions above.
Running as root
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.
When not running gem as root, the gems will be installed into ~/.gem and not affect anyone else, although it might be worth noting that not all gems are happy to be installed in this way and might insist on being installed by root (especially if they have native extensions).
Bundler solves these problems to some extent by packaging gems into your application. See the section below on using bundler.
# gem update --system
Installing a gem
This example installs the MySQL ruby gem:
# gem install mysql
The process can be speeded up somewhat if you don't need local documentation:
# gem install mysql --no-rdoc --no-ri
The gem will now be downloaded, compiled if necessary, and installed.
Bundler installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of Ruby On Rails applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.
It might be a good idea to install bundler as a system-wide gem so everyone can use it:
# gem install bundler
To start a new bundle:
# bundle init
Then add your required gems into "Gemfile" in the current directory (created by bundle init):
gem "rails", "2.3.4" gem "mysql"
Finally, run the following to install your gems. They will all be installed locally into ~/.bundle, eliminating the need for root access:
# bundle install