Ruby Rails with minimal Postgres


Today I learned how to build a Rails app without having all of Postgres installed on my machine. My whole purpose is to avoid adding too much software to my Mac. I am running Postgres in a Docker container instead. I hit a snag because it appeared that the pg gem needed all of Postgres installed. doing a bundle install on the project was giving me an error about a missing pg_config. Not knowing much I googled around and everywhere I looked seemed to indicate that you have to run brew install postgresql to work around the error. After discussing with a colleague I realized I just needed the PG APIs which live in the libpq brew formulae. The actual solution is to brew install libpq then export PATH=$PATH:/usr/local/opt/libpq/bin to allow the Ruby to find the pg binaries required to build the gem. I’m parking this tip here for the future me who will come back in a year or so puzzled as to how I accomplished this. Future me, you’re welcome!