Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Trouble installing DBD::Pg

by frankdew (Initiate)
on Aug 14, 2009 at 18:20 UTC ( [id://788719] : perlquestion . print w/replies, xml ) Need Help??

frankdew has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I've made a perl script that installs PostgreSQL, DBI and then DBD::Pg. Its does install Postgre and DBI correctly, but fails to install DBD::Pg. If I run the script a second time, it does install DBD::Pg correctly. I just dont understand why.
I'm running the script in sudo mode... here is a snippet from my code:
system("sudo aptitude update"); if ( $? == -1 ) { print "sudo aptitude update failed: $!\n"; exit; } system("sudo aptitude install postgresql-server-dev-8.3"); if ( $? == -1 ) { print "sudo aptitude install postgresql-server-dev-8.3 failed: $!\n" +; exit; } use CPAN; CPAN::Shell->install("DBI"); CPAN::Shell->install("DBD::Pg"); ----------
The first time, it fails with the following message:
Running make test
PGINITDB="/usr/lib/postgresql/8.3/bin/initdb" PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
        all skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic...........NOK 2
#   Failed test 'use DBD::Pg;
#   at t/00basic.t line 14.
#     Tried to use 'DBD::Pg'.
#     Error:  DBD::Pg object version undef does not match bootstrap parameter 2.15.1 at /usr/lib/perl/5.8/ line 245.
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Cannot continue without DBD::Pg
make: *** test_dynamic Error 9
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force.

Can somebody help me solve this problem ? I would like to understand why it works on the second run. Thank you for your help monks!

Replies are listed 'Best First'.
Re: Trouble installing DBD::Pg
by Anonymous Monk on Aug 15, 2009 at 00:47 UTC
    I would uninstall DBD::Pg in your program before trying to install it. I would also upgrade CPAN and ExtUtils::MakeMaker before trying to replicate the problem again. I would also turn on debugging/verbose mode to get more diagnostic output.
      Seems as if nobody has a clue about my problem. I've tried the hints by anonymous monk without any success.
        The error message is the clue. You've got conflicting mismatching files. Either get rid of them (delete/overwrite), or install to a different location, or call the right perl binary ($PATH), or sanitize your environment variables (PERLLIB/PERL5LIB).
        i have same problem when installing DBD::Pg 2.15.1 after uninstalling dbi package (on ubuntu), i try to install DBI latest version from cpan and reinstall DBD::Pg again using cpan. now the problem solve. so, i think the problem is unmatched the DBI version.
Re: Trouble installing DBD::Pg
by markjugg (Curate) on Dec 30, 2011 at 19:16 UTC
    I think I can demystify this some. DBD::Pg gets compiled against a specific version of DBI. If you compile it against one version, but try to use it with a different version, you might get this error.

    If you are installing DBD::Pg manually, it will tell you which version of DBI it is being compiled against. If it is not choosing the version you want, you can explicitly set PERL5LIB so that the version you want is found first. (Perhaps it is finding a global version of DBI, but you want to use a private use version of DBI).

    Finding the global DBI:

    $ perl Makefile.PL
     Using DBI 1.604 (for perl 5.008002 on i386-freebsd) installed in /usr/local/lib/perl5/site_perl/5.8.2/mach/auto/DBI/
    Finding a local DBI:
    $ PERL5LIB=/home/sap/betasite/perllib perl Makefile.PL
     Using DBI 1.616 (for perl 5.008002 on i386-freebsd) installed in /home/sap/betasite/perllib/i386-freebsd/auto/DBI/
Re: Trouble installing DBD::Pg
by Anonymous Monk on Jun 01, 2010 at 22:13 UTC
    I got the same error while trying to install DBD::Pg through CPAN, I updated CPAN, reloaded it, and then was able to successfully install Pg.