Installing ruby postgres and mysql gems on Leopard

Leopard comes with ruby preinstalled. Most of us use macports to install postgresql & mysql for use with rails, which I recommend -

sudo port install mysql5 +server
sudo port install postgresql82
sudo port install postgresql82-server

(The postgresql package wasn't compiling on Leopard at release, but it's all happy now.)

However, when it comes to the ruby client library bindings (for both database servers), if you install the macports packages, it'll build its own ruby (still 1.8.6, though a later patchlevel).

That actually works just fine – it will come first in your PATH and so will get used instead of the version that comes with Leopard, but it won't clobber the files so you can always go back – but personally, I don't like the idea of having two sets of ruby stuff on my machine.

So I wanted to stick with the Leopard ruby install and install the ruby bindings via the gems, rather than via macports directly.

However, those gems still need to know where you (or in our case, macports) put the database client libraries.

Easily done:

sudo env ARCHFLAGS="-arch `uname -m`" gem install postgres --\


sudo env ARCHFLAGS="-arch `uname -m`" gem install mysql -- \
  --with-mysql-include=/opt/local/include/mysql5/mysql/ \