Oisín Hurley's Weblog

old dog, new tricks

Installing the DataMapper gem with Postgres.app

with 4 comments

Another install-related entry. This time, I’m attempting to install the Ruby Gem, DataMapper, for a small project – a mini app for pulling S3/Cloudfront download stats for my Verbose (iTunes link) podcast. The app pulls a date range worth of logs from S3, then digests the logs, putting the relevant data into a Postgres database, so they can be mangled at will later. 

I’ve installed Postgres.app on my MacBook Air, because I like the icon. I could have homebrew‘ed the database in, but since I don’t use it that often, it’s trivial to remove when bundled into the app. DataMapper has worked well for me in the past, so I’m sticking with it.

The whole reasoning behind using Postgres in the first place is that both AppFog and Heroku support it as their default SQL database. There’s no performance constraints, or scaling requirements here, since this is just a tiny, personal app. The main technology consideration is get-out-of-my-way-and-let-me-get-this-done-for-cheap.

But there’s always something. In this case it’s installing a Ruby gem with native extensions, when the collateral for building those extensions resides in a non-default location. 



Making the install work involves using bundle config, an aspect of Bundler I didn’t know about. It allows you to override the arguments to the configure execution for native gem components. You can directly override when installing a gem, or you can register an override that will be stored in your ~/.bundle directory and remembered for future use. 

Here’s the incantation that worked for me, for a once-off install:

gem install do_postgres -- \
--with-pgsql-server-dir=/Applications/Postgres.app/Contents/MacOS \

Written by oisinhurley

September 14, 2013 at 2:03 pm

4 Responses

Subscribe to comments with RSS.

  1. thanks so much, this helped me out a ton


    February 7, 2014 at 2:24 am

  2. Thanks for the writeup! But with the latest Postgres.app (, they changed the paths. Here’s the updated command to install the do_postgres gem:

    gem install do_postgres — \
    –with-pgsql-server-dir=/Applications/Postgres.app/Contents/Versions/9.3 \


    February 26, 2014 at 1:07 am

  3. Thank you Raj. Thank you so so so much! I have spent hours trying to figure out the right parameters to send so it picks up the do_postgres properly.

    I am on El Capitan and installed postgres 9.3.10 from EnterpriseDB.

    For me, this worked (highly inspired from you) :

    sudo gem install do_postgres -v 0.10.2 — –with-pgsql-server-include=/Library/PostgreSQL/9.3/include/postgresql/server –with-pgsql-server-dir=/Library/PostgreSQL/9.3/


    February 11, 2016 at 11:55 am

  4. For Postgres 9.5.2 and a Homebrew installation, I found I needed:

    sudo env ARCHFLAGS=”-arch x86_64″ gem install do_postgres — –with-pgsql-server-dir=/usr/local/Cellar/postgresql/9.5.2 –with-pgsql-server-include=/usr/local/Cellar/postgresql/9.5.2/include/server

    Richard Fairhurst

    June 26, 2016 at 2:45 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: