I need to fix a project which uses PostgreSQL. On a fresh Leopard install with postgresql 8.3 installed from ports I ran into this problem:
$ sudo gem install pg Building native extensions. This could take a while... ERROR: Error installing ruby-pg: ERROR: Failed to build gem native extension.
The solution is quite simply. Just make sure pg_config can be found by the gem installer.
$ mdfind pg_config|grep bin|uniq /opt/local/lib/postgresql83/bin/pg_config
In this case make sure /opt/local/lib/postgresql/bin is available in the path when executing the gem command
$ PATH=/opt/local/lib/postgresql83/bin:$PATH sudo gem install pg