Peter Mellett

Stylised cartoon of me with glasses on.

Installing pg Gem on OS X Lion

After spending a frantic 20 minutes trying to find a way to install the pg gem on OS X Lion, I discovered this solution.

I had installed Postgres through homebrew and the instructions were not clear on where the pg_config file was installed. brew info postgresql recommends ensuring you set the correct architecture in an environment variable to build the x64 version with ARCHFLAGS='-arch x86_64' gem install pg which didn't work in my case.

Suggested elsewhere was to specify the pg_config file location to the postgres gem, but no mention of where this file may be found. After a not-so-quick search (the ridiculous find / pg_config | grep pg_config) I found it at /usr/local/bin/pg_config the file will be elsewhere if you installed from source.

Before you bundle install - to a terminal full of make errors - install the pg gem with:

1 gem install pg -- --with-pg-config=/usr/local/bin/pg_config

You may need to run sudo gem install [...] if you are not using a version manager like RVM or Rbenv.

Headache averted.

Home