Question

Postgres DB is already installed. I'm not using system perl I have installed another perl in "/srv/data203806/Migration/CPAN/localperl/bin". When I'm trying to install, It is asking for PATH TO pg_config:

[root1@frmrszvwb023 bin]# ./cpan install DBD::Pg
Reading '/root/.cpan/Metadata'
  Database was generated on Fri, 07 Mar 2014 03:53:02 GMT
Running install for module 'DBD::Pg'
Running make for T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz
Checksum for /root/.cpan/sources/authors/id/T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz ok

  CPAN.pm: Building T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz

    Configuring DBD::Pg 3.0.0
    Path to pg_config?
    No POSTGRES_HOME defined, cannot find automatically
    Warning: No success on command[/srv/data203806/MUXmh-Migration/CPAN/localperl/bin/perl Makefile.PL]
    'YAML' not installed, will not store persistent state
      TURNSTEP/DBD-Pg-3.0.0.tar.gz
      /srv/data203806/MUXmh-Migration/CPAN/localperl/bin/perl Makefile.PL -- NOT OK
    Running make test
      Make had some problems, won't test
    Running make install
      Make had some problems, won't install
    Could not read metadata file. Falling back to other methods to determine prerequisites

Please help me to install DBD::Pg? How to get path to pg_config?

Was it helpful?

Solution 2

You have to install libpq-dev, e.g. on Ubuntu:

sudo apt-get install libpq-dev

OTHER TIPS

Just ran into this issue, and on Ubuntu 16.04 Xenial the package you're looking for is:

apt-get install libdbd-pg-perl

On CentOS/RH you can fix it by installing perl-DBD-Pg package with yum

sudo yum install perl-DBD-Pg

From the README:

INSTALLATION:

Before installing, please use the "cpansign -v" program to cryptographically verify that your copy of DBD::Pg is complete and valid. The program "cpansign" is part of Module::Signature, available from CPAN.

By default Makefile.PL uses App::Info to find the location of the PostgreSQL library and include directories. However, if you want to control it yourself, define the environment variables POSTGRES_INCLUDE and POSTGRES_LIB, or define just POSTGRES_HOME. Note that if you have compiled PostgreSQL with SSL support, you must define the POSTGRES_LIB environment variable and add "-lssl" and "-lcrypto" to it, like this:

export POSTGRES_LIB="/usr/local/pgsql/lib -lssl -lcrypto"

The usual steps to install DBD::Pg:

  1. perl Makefile.PL
  2. make
  3. make test
  4. make install

Do steps 1 to 2 as a normal user, not as root!

If the script cannot find the pg_config information itself, it will ask you for the path to it. Enter the complete path to the pg_config file here, including the name of the file itself.

If you want to use a module, read the documentation.

Before installing perl module, you must install client for accessing Postgres DB. I just install server and header files:

sudo apt-get install postgresql
sudo apt-get install libpq-dev

You can try:

locate pg_config

This will show something like:

/usr/pgsql-10/bin/pg_config
/usr/pgsql-10/include/ecpg_config.h
/usr/pgsql-10/include/ecpg_config_x86_64.h

Then run:

POSTGRES_HOME=/usr/pgsql-10 ./cpan install DBD::Pg

UPD

If you still encounter issues with pg_config, you may need to add it to your PATH, e.g.:

export PATH=$PATH:/usr/pgsql-x.x/bin

where x.x is your version, such as /usr/pgsql-9.2./bin.

Fedora 29, plenv, perl v5.18.0

Once I got plenv working, I was able to install DBD::Pg with cpanm using these commands:

sudo dnf install postgresql postgresql-devel
cpanm --quiet --notest DBD::Pg

For ArchLinux (or any Distro using Pacman):

pacman -S perl-dbd-pg

For my Ubuntu 22 worked this:

sudo apt install build-essential
sudo apt install cpanminus
sudo apt-get install -y postgresql-server-dev-all
sudo cpanm DBD::Pg
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top