PG Gem woes, not for the first time.

If you encounter errors installing pg gem on an Apple Silicon mac:

checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header

Then try the below commands firstly; to ensure the homebrew version of libpg is used:

echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
gem install pg -- --with-pg-config=`which pg_config`

and follow up with bundle install once successful.

This worked for me with the Postgres.app (postgres 14), and having previously installed libpq:

brew install libpq@14.6
James Cowlishaw @Cowlibob
Mastodon