Added on Jun 16th, 2012 and marked as install ruby

Install using rvm

To install ruby, we first install rvm:

apt-get install ruby-rvm

If you get the following error:

dpkg-statoverride: error: syntax error: unknown group 'admin' in statoverride file
dpkg: error processing ruby-rvm (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 ruby-rvm
E: Sub-process /usr/bin/dpkg returned an error code (1)

you have to create a new group called admin:

addgroup admin

To install the most recent stable ruby version:

curl -L get.rvm.io | bash -s stable
usermod -a -G rvm <user>
source /etc/profile.d/rvm.sh
rvm install 1.9.3

List all available ruby versions:

rvm list

Install using apt-get

Sometimes it doesn’t work installing ruby with rvm (not sure why it fails, have to take a look into that in the future). In that case you can install it with apt-get. Make sure you specify the correct ruby package, or you might end up with version 1.8.

apt-get install ruby1.9.3

This will install version 1.9.3-p0, not 1.9.3-p194 as with rvm (at the moment of writing).

To make things even more complicated, you might run into the following errors when installing certain gems (I encountered this with charlock_holmes and json):

ERROR:  Error installing charlock_holmes:
        ERROR: Failed to build gem native extension.
        /usr/bin/ruby1.9.1 extconf.rb
        /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from extconf.rb:1:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/charlock_holmes-0.6.8 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/charlock_holmes-0.6.8/ext/charlock_holmes/gem_make.out

Installing json (1.7.3) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
        /usr/bin/ruby1.9.1 extconf.rb
        /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from extconf.rb:1:in `<main>'
Gem files will remain installed in /home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/json-1.7.3 for inspection.
Results logged to /home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
An error occured while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.

Both problems could be resolved by installing ruby1.9.1-dev:

apt-get install ruby1.9.1-dev