Installing the `pg` Ruby Gem with a Postgres.app installation
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, lib and 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".
Postgres.app – the easiest way to get started with PostgreSQL on the Mac
Postgres.app is a full featured PostgreSQL installation packaged as a standard Mac app.