if you are running on Linux you may be interested in what worked for me:

sudo apt-get install postgresql
sudo apt-get install libpq-dev

Then

gem install pg

then

bundle install

src: http://wikimatze.de/installing-postgresql-gem-under-ubuntu-and-mac


As stated in your error log you need to pass in the path to the pg_config. Try to install the gem using:

gem install pg -- --with-pg-config= 'PATH_TO_YOUR_PG_CONFIG'

If you are not sure where your pg_config is, and assuming you are on Linux or Mac, you can run the following command:

which pg_config

Your pg-config can be in different locations depending on how you installed postgres.