1

I had a problem similar to this one, on my Docker host computer. I was able to fix it by installing libpq-dev on the host machine, as suggested.

But when I create a Docker image using ubuntu:16.04 as a base, I get the same error, but none of the suggested answers seem to work.

I've exec'd into the container and installed all the suggested packages but I keep getting back the error message:

Can't find the PostgreSQL client library (libpq)
*** 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.

Provided configuration options:     --with-opt-dir  --with-opt-include  --without-opt-include=${opt-dir}/include    --with-opt-lib  --without-opt-lib=${opt-dir}/lib    --with-make-prog    --without-make-prog     --srcdir=.  --curdir    --ruby=/opt/puppetlabs/puppet/bin/ruby  --with-pg   --without-pg    --enable-windows-cross  --disable-windows-cross     --with-pg-config    --without-pg-config     --with-pg_config    --without-pg_config     --with-pg-dir   --without-pg-dir    --with-pg-include   --without-pg-include=${pg-dir}/include  --with-pg-lib   --without-pg-lib=${pg-dir}/lib  --with-pqlib    --without-pqlib     --with-libpqlib     --without-libpqlib  --with-ms/libpqlib  --without-ms/libpqlib

extconf failed, exit code 1

Gem files will remain installed in /opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/pg-0.20.0 for inspection. Results logged to /opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/pg-0.20.0/gem_make.out

I'm wondering if this might be an issue of the package being installed but not found for some reasons? Any ideas to go about debugging?

Community
  • 1
  • 1
Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
  • What version of psql are you using? I had a conflict between the pg gem and psql 9.6, but I eventually fixed it but creating a symlink to pg_config via `ln -sf /usr/pgsql-9.6/bin/pg_config /usr/bin/` that enabled pg to find the relevant include directories and libraries... – Brian May 08 '17 at 15:17
  • @Brian I'm using 9.5.3 but it's installed on a server separate from the one with my python script. – Philip Kirkbride May 08 '17 at 16:03
  • Did `mkmf.log` give you any additional information? – coreyward May 08 '17 at 16:23
  • @PhilipKirkbride There needs to be some version of the postgres client installed on the machine that you're trying to build the pg gem on, no? On redhat, I install "postgresql96" and "postgresql96-devel". – Brian May 08 '17 at 18:04
  • 2
    @Brian I did use `apt-get install libpq-dev` so hopefully that would be the client. When you said `psql` I assumed you meant the full postgres installation. Do you know how I can check the client version? – Philip Kirkbride May 08 '17 at 18:06
  • @PhilipKirkbride If you run `psql --version` it should show the version. – Brian May 08 '17 at 18:13
  • @Brian I get `psql: command not found` but I get something similar on my host computer and the script works perfectly. Doesn't `psql` refer to the actual postgres database? I ask because I always use `psql` command on the server that actually has postgres installed when I need to make modifications. – Philip Kirkbride May 08 '17 at 18:26
  • @PhilipKirkbride psql is the front-end client for Postgres that you can use to interact with a Postgres server. The server can be running on the same machine as psql, or on a remote server. `libpq-dev` is just the include files and libraries, but I needed `postgres96-devel` on redhat as well to build `pg`. – Brian May 08 '17 at 20:47

0 Answers0