I am trying to install the pg gem for use with Postgres.app on my local machine. I am running Mavericks.
Postgres.app is installed and running fine, but I cannot get
You probably have the wrong path for --with-pg-config
, check if it's actually there.
You can find the correct path to pg_config
with:
find /Applications -name pg_config
In the latest Postgres.app Version the path is:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
Being on a brand new mac, here's what I had to do:
Now run (hopefully a future-proofed command):
version=$(ls /Applications/Postgres.app/Contents/Versions/ | tail -1)
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/$version/bin/pg_config .
If you have trouble, you can troubleshoot a bit by checking out the actual error in the mkmf.log which you can find by running (if using rvm):
cd ~/.rvm ; find . -name mkmf.log | grep pg
In my case (running Postgres.app v9.3.4.2) it only seemed to work when prepending the environment architecture flags:
env ARCHFLAGS="-arch x86_64" gem install pg -- \
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
To resolve this issue I installed postgres using homebrew using the following in the terminal window:
brew install postgres
Homebrew can be found here
http://brew.sh
This worked for me:
gem install pg -- --with-pg-config=`which pg_config`
For future reference, since a lot of us are posting new paths for the new version numbers:
Currently I'm seeing a symlink called latest
in /Applications/Postgres.app/Contents/Versions/
.
You should be able to just do:
$ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
And forget about the version number. This might not apply to every (older) version, but I myself was looking for a snippet I could save and reuse.