Whenever I run `bundle install` on my VPS (CentOS Linux release 7.0.1406 (Core)) I get an error when installing the pg gem.

```
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

```

I can install pg standalone with: `gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config` and the issue is resolved.

So I added a capistrano taskto create a ./bundle/config for the deploy with the build.pg key set with the path to pg\_config on my VPS. In the Capistrano `config/deploy.rb` this is invoked `before bundler:install`.

```
desc "Create bundle config"
task :prepare_bundle_config do
  on roles(:app) do
    within release_path do
      execute :bundle, 'config build.pg --with-pg-config=/usr/pgsql-9.4/bin/pg_config --local'
    end
  end
end

```

I have the necessary packages installed:

```
postgresql94-server.x86_64
postgresql94-devel.x86_64
postgresql94-libs.x86_64
libpqxx.x86_64
libpqxx-devel.x86_64

```

Here are the capistrano\* gems I have installed

```
bundle list | grep capistrano
* capistrano (3.3.5)
* capistrano-bundler (1.1.4)
* capistrano-rails (1.1.2)
* capistrano-rbenv (2.0.3)
* capistrano-stats (1.1.1)

```

What am I missing here to successfully install pg with bundler? Please leave a comment if you need any additional information and I will update this post.