install gem pg on yosemite with postgresapp installed

If you have trouble to install the postgres-gem on your mac (yosemite or any later mac os-x version) with postgresapp installed, you probably get an error message like this:

ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details.


1) set the pg-path like this
Add the following line to your ~/.bash_profile

export PATH=$PATH:/Applications/


2) install pg-gem manually

sudo ARCHFLAGS="-arch x86_64" gem install pg -v '0.17.1'
comments powered by Disqus