pg gem install fails, cannot find libpq-fe.h header

The postgres binaries are not in the path. Symlink them in to a directory in your path and you should be good: ln -s /usr/pgsql-9.4/bin/p* /usr/local/bin.

Did you build postgres or install it from yum?


Just posting the solution for PostgreSQL 11. If someone lands here.

sudo yum install epel-release

sudo yum install postgresql11-llvmjit

sudo yum install postgresql11-devel postgresql11-libs

Then run

gem install pg -v '1.2.3' -- --with-pg-config=/usr/pgsql-11/bin/pg_config 

Thats it