install pg with native extension error

I was getting trouble to install pg gem. The error i was getting is

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

I also found some tips on SO. It was to locate the postgre’s config (pg_config) to bundler before running `bundle install` command. For general postgresql installation,

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

(path was not same for me on Mac OSx. It was /Library/PostgreSQL/9.1/bin/pg_config)

But this did not solve my problem. I was still getting the same error when i was running bundler. However, when i tried to install the gem separately with this directive set, it worked fine.

gem install pg -- --with-pg-config=/Library/PostgreSQL/9.1/bin/pg_config

Now the gem is installed fine and i ran the `bundle install` and it was installed without issues.

Try it!