संभवतः आपके पास --with-pg-config . के लिए गलत पथ है , जांचें कि क्या यह वास्तव में वहां है।
आपको pg_config . का सही रास्ता मिल सकता है साथ:
find /Applications -name pg_config
नवीनतम Postgres.app संस्करण में पथ है:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config