Oisín Hurley's Weblog

old dog, new tricks

Installing the DataMapper gem with Postgres.app

with 2 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. 

Image

 

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 \
--with-pgsql-server-include=/Applications/Postgres.app/Contents/MacOS/include/server
About these ads

Written by oisinhurley

September 14, 2013 at 2:03 pm

2 Responses

Subscribe to comments with RSS.

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

    duncangraham

    February 7, 2014 at 2:24 am

  2. Thanks for the writeup! But with the latest Postgres.app (9.3.2.0), 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 \
    –with-pgsql-server-include=/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server

    Raj

    February 26, 2014 at 1:07 am


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 3,981 other followers

%d bloggers like this: