One-liner to get a precompiled Ruby on your own servers

0 comments

At Packager we maintain ruby binaries for all the distributions we support (Debian / Ubuntu / CentOS / RHEL / Fedora), regularly updated to keep up with patch releases.

Even without using our packaging service, it's actually pretty useful to just get Ruby and Rubygems installed on a new server in no time.

It's similar to what you can achieve with RVM.io or rbenv, but you don't need to install any tool, and the binaries make no assumption that they'll be running under RVM or rbenv.

For instance, let's say you wanted to install Ruby 2.1.4 on a Ubuntu 14.04 server:

    $ curl https://s3.amazonaws.com/pkgr-buildpack-ruby/current/ubuntu-14.04/ruby-2.1.4.tgz -o - | sudo tar xzf - -C /usr/local

    $ ruby -v
    ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]

    $ gem -v
    2.2.2

Replace ubuntu-14.04 and 2.1.4 in the cURL command with, respectively, any of the supported distributions and any of the supported ruby versions (coming back to ruby 1.9.2), and you're good to go:

Debian

    $ curl https://s3.amazonaws.com/pkgr-buildpack-ruby/current/debian-7/ruby-2.1.4.tgz -o - | sudo tar xzf - -C /usr/local

Ubuntu

    $ curl https://s3.amazonaws.com/pkgr-buildpack-ruby/current/ubuntu-14.04/ruby-2.1.4.tgz -o - | sudo tar xzf - -C /usr/local

    $ curl https://s3.amazonaws.com/pkgr-buildpack-ruby/current/ubuntu-12.04/ruby-2.1.4.tgz -o - | sudo tar xzf - -C /usr/local

CentOS / RHEL

    $ curl https://s3.amazonaws.com/pkgr-buildpack-ruby/current/centos-6/ruby-2.1.4.tgz -o - | sudo tar xzf - -C /usr/local

Fedora

    $ curl https://s3.amazonaws.com/pkgr-buildpack-ruby/current/fedora-20/ruby-2.1.4.tgz -o - | sudo tar xzf - -C /usr/local

Security: Note that you can extract the archive into any directory, which may be better if you don't want to run tar as root, or pollute your /usr/local directory. For instance:

    $ curl https://s3.amazonaws.com/pkgr-buildpack-ruby/current/ubuntu-14.04/ruby-2.1.4.tgz -o - | tar xzf - -C ~/custom/path

    $ ~/custom/path/bin/ruby -v
    ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]

    $ ~/custom/path/bin/gem -v
    2.2.2

In that case, you need to specify the full path to the binaries, or add it to your $PATH.

Enjoy!