An error occurred while installing pg (0.17.1), and Bundler cannot continue

Some kind of error resported here Installing PG gem on OS X - failure to build native extension

To install dependencies on Ubuntu try this:

sudo apt-get install libpq-dev

and this

gem install pg

I'm on a Mac running Mavericks. My solution was to install Postgres.

And then in terminal install using homebrew with the configuration:

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

Note: This answer has been edited to use the latest symlink that is currently included in shipping versions of the Postgres app.

Previous versions suggested:

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