Same error for me and I didn’t experience it until I downloaded OS X 10.9 (Mavericks). Sigh, another OS upgrade headache.
Here’s how I fixed it (with homebrew):
- Install another build of Xcode Tools (typing
brew updatein the terminal will prompt you to update the Xcode build tools) brew updatebrew install postgresql
After that gem install pg worked for me.