Sold on Homebrew
I’m starting a new Rails project. I want to use Ruby 1.9.3 from the beginning to ease a future upgrade to Rails 4.0, which will require it. This presented a few issues I had to work through for my development and production environments.
Mac OS X ships with Ruby 1.8.7, but I’ve been using RVM to manage different Ruby versions in development and it’s worked fine. Debian is my preferred server distribution and the latest stable release includes Ruby 1.9.2-p0.
I’m not completely comfortable with using RVM in a production environment, and I don’t want to take on the work of installing my own Ruby entirely by hand, so this led me to look at rbenv, a lightweight alternative to RVM. It seems better suited for use in a production environment. I like to match development to production when possible so there are less things to remember, and so I switched to rbenv on my development machine, as well. Paired with ruby-build, it gives me the important features I used from RVM (I never made much use of gem sets).
It did not go well.
$ rbenv install 1.9.3-p0 $ RBENV_VERSION=1.9.3-p0 gem install bundler rails $ rbenv rehash $ RBENV_VERSION=1.9.3-p0 rails new app ... /Volumes/User/Steve/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0]
Searching for solutions led me to suspect that this is due to a library version mismatch between the compiled Ruby and a gem. MacPorts can make this more common, because unlike Homebrew, it imposes strict control over dependencies and will install a new version of something (e.g., OpenSSL) even if Mac OS X ships with an older one that would work fine.
Rather than track down the problem library, then figure out how to ask rbenv to link with a different version of it, I decided to try Homebrew.
It worked flawlessly. The error when creating a new Rails project is gone.
What really sealed the deal for me came next. I like PostgreSQL, partly because it supports additional data types that can be very useful. One example is cube, which is used by the earthdistance extension to store locations and do fast proximity searches. On MacPorts, installing those “contrib” extensions is a manual, clunky process. On Homebrew, all the contrib extensions are already compiled and available.