Problem
When installing the pg gem, you might encounter the following error:
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. You may
need configuration options.
This usually means the PostgreSQL development headers are missing.
Solution
To resolve this issue, you need to install PostgreSQL
brew install postgresql
After installing PostgreSQL, you can retry the installation of the pg gem
# Install the pg gem
gem install pg
# or if you're using Bundler
bundle install