Skip to content

Instantly share code, notes, and snippets.

@anbotero
Created August 6, 2012 18:33
Show Gist options
  • Save anbotero/3277371 to your computer and use it in GitHub Desktop.
Save anbotero/3277371 to your computer and use it in GitHub Desktop.
Ruby on Steroids
before_install_package() {
local package_name="$1"
if [[ "$package_name" == *ruby-1.9.3-p194* ]]; then
{
curl https://raw.github.com/gist/2593385/perf_and_gc.diff | patch -p1
curl https://raw.github.com/gist/2981959/ary-queue.diff | patch -p1
} >&4 2>&1
fi
}
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.3-p194" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz" autoconf standard

This asumes we’re using homebrew on Mac OS X (10.6+) and that everything runs smoothly without issues.

We need to set up a few things before we move on with the actual install of Ruby:

$ brew install autoconf
$ brew install openssl
$ brew install readline
$ brew tap homebrew/dupes
$ brew install libiconv
$ brew install ruby-build
$ brew install llvm --with-clang --shared
$ hash -r

This next step varies based on what Ruby version manager you use:

  • RVM:
    $ rvm get head && rvm reinstall 1.9.3-p194 --patch falcon --with-openssl-dir="$(brew --prefix openssl)" --with-readline-dir="$(brew --prefix readline)" --with-iconv-dir="$(brew --prefix libiconv)"
  • rbenv:
    $ CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline) --with-iconv-dir=$(brew --prefix libiconv)" CC="clang" rbenv install 1.9.3-p194-steroids
  • rbfu
    $ CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline) --with-iconv-dir=$(brew --prefix libiconv)" CC="clang" ruby-build 1.9.3-p194-steroids ~/.rbfu/rubies/1.9.3-p194-steroids

I’ve not been much of an RVM user for development for some time now, so I can’t vouch for that method to work. Besides, the patch they use is a copy from the original gist and, to this date (06/08/2012), it’s not yet updated to the latest. Also, said patch does not implement an additional modification to improve Arrays performance.

In case you use a verbose output setting, don’t worry about the YAML package reporting unknown options --with-openssl-dir, --with-readline-dir and --with-iconv-dir. They’re are just for the Ruby package, but since we’re including them for the whole process, they are also used for YAML. It’s harmless, really.

We’re compiling Ruby against the ICONV library because there are some gems that still use it. But it will be deprecated in future versions of Ruby, so we should consider to slowly phase it out...

These days I use rbfu, and a .ruby-version file on my $HOME, so as soon as I load my terminal, I get this version loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment