There are variations of this question bouncing around SO, but none of them seem to have an answer that solves my problem.
I am running OSX Lion (10.7.3). The latest
Installing xcode from the app store is not enough. You will also need xcode's command line tools. https://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_3.html
After installing xcode from the app store, open xcode. Goto Xcode->Open Developer Tool->More Developer Tools Download and install the latest command line tools.
Open a terminal window and run: sudo gem install pg