Install the pg gem in a Homebrew environment
Topics: Homebrew, Ruby gems, PostgreSQL
When Postgresql, or rather libpq, is installed via Homebrew, installing the pg gem will require you to provide information on where to find its include and library files.
Installation via gem
To install install the gem directly:
gem install pg -- \
--with-pg-config=$(brew --prefix libpq)/include \
--with-pg-lib=$(brew --prefix libpq)/lib
Installation via bundler
For Bundler, it’s ideal to store the build configuration centrally:
bundle config --global build.pg \
--with-pg-include=$($brew --prefix libpq)/include \
--with-pg-lib=$(brew --prefix libpq)/lib
bundle install