Installing the pg PostgreSQL gem on Mac OS X
I’ve recently switched from using MySQL to PostgreSQL for my Ruby projects. You can connect to a PostgreSQL database from Ruby using the pg gem, but if the pg_config program isn’t in your path you’ll run into problems during installation.
1 | $ sudo gem install pg |
A few minutes later I realised I’d installed my copy of PostgreSQL using the one click installer, which puts the database server in the /Library/PostgreSQL directory. This sorted it:
1 | $ PATH=$PATH:/Library/PostgreSQL/8.3/bin sudo gem install pg |
on mojave with postgress.app
1 | gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/11/bin/pg_config |