If you are using the Postgres.app to manage PostgreSQL installations on your Mac, and you want to install the
pg Ruby gem, you want to point to where the binaries,
include directories are. The command looks like:
gem install pg -- --with-pg-dir=/Applications/Postgres.app/Contents/Versions/16
The point is that the
pg-dir is in the application bundle for the app in your
Applications folder. That directory might be different, depending on the installation. You can find it in the application itself, by clicking on the “Show” button in “Server Settings” -> “Binaries”.