Pg gem install fails, cannot find libpq-fe.h header

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

 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 autonomously using gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config and the problem will be solved.

So, I added the capistrano task to create. / bundle / config to deploy using the build.pg set installed on the path to pg_config on my VPS. In Capistrano config/deploy.rb this is called 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 Caspans * gems that I set

 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 more information and I will update this post.

+7
centos7 pg centos bundler capistrano
source share
2 answers

Postgres descriptors are not in the path. Symlink them to a directory in your path, and you should be good: ln -s /usr/pgsql-9.4/bin/p* /usr/local/bin .

Did you build postgres or install it from yum?

+18
source share

I find that if I compile pgsql with source code and PATH ENV is not configured with pgsql / bin, this will happen. You can try with this.

0
source share

All Articles