Impossible to Install PG gem on my mac with Mavericks

Use brew to get postgresql

brew install postgresql

Check you have pg_config in the installed brew. I found mine in

/usr/local/Cellar/postgresql/9.3.3/bin/pg_config

Check via :

$ ls /usr/local/Cellar/postgresql/9.3.3/bin/pg_config
> /usr/local/Cellar/postgresql/9.3.3/bin/pg_config

Once done, install the pg gem with

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.3/bin/pg_config

If you want to avoid using MacPorts, you can download the Postgres App and place it into the Application directory.

Then, specify the location of newly downloaded pg_config:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config

If you run in to missing headers problem, try specifying the include directory of the app:

gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/Versions/latest/include/'

I wasn't able to install postgres via MacPorts. Instead, I installed Postgress.app. and called

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config

Note: in newer versions (in 9.3 at least) the path is actually: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config