The "High Sierra" build of macOS X removed a legacy folder path where some library files are generally installed for tools that need to be compiled. If you click on the 'apple' icon in the top left corner of your screen, if the text in large font says something like "macOS High Sierra" then this set of instructions could help fix some problems for you.
If you have installed PostgreSQL before upgrading to High Sierra, this may not affect you and these installation notes may not help.
If your Macbook came with High Sierra, or you've upgraded to High Sierra before installing PostgreSQL, this may affect you and you can keep reading.
Assumptions:
- you're using Homebrew
At a high level, we're going to uninstall PostgreSQL, set up this legacy path, re-install PostgreSQL and then install the PostgreSQL gem for Ruby.
- Uninstall PostgreSQL
brew uninstall postgresql
This should not delete any existing databases, especially if you're using Homebrew, it will only remove the binary files of the PostgreSQL software itself.
- Create the legacy path and set its ownership
sudo mkdir /usr/local/include
sudo chown -R `whoami`: /usr/local/include
- Re-install PostgreSQL
brew install postgresql
brew services start postgresql
- Install the "pg" gem
gem install pg -v 0.21.0
this saved me thanks!!!