Executing a .cgi from the command-line (as the user who has access to the db), I get
install_driver(Pg) failed: Can't locate DBD/Pg.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at (eval 4) line 3. Perhaps the DBD::Pg perl module hasn't been fully installed, or perhaps the capitalisation of 'Pg' isn't right.
cpan -D DBD::Pg shows
DBD::Pg
Postgres Driver for DBI T/TU/TURNSTEP/DBD-Pg-2.19.2.tar.gz /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/DBD/Pg.pm Installed: 2.19.2 CPAN: 2.19.2 up to date DBD::Pg Developers (DBDPG) dbd-pg@perl.org
Trying to export above path by PERL5LIB or PERLLIB has no different outcome.
The .cgi references /usr/bin/perl, which tells
This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail)
I like to permanently set the module path to the one where DBD::Pg is installed (/opt/...). I wonder why that is not mentioned by the error outputs directory listing.
I installed DBD::Pg via cpanm.
I use Mac OS X Mountain Lion.
You appear to have two different builds of Perl installed. The one with which you are running your script is different than the one used to run cpan
. To install DBD::Pg with the correct Perl, use
perl -MCPAN -e'install DBD::Pg'
Replace perl
with the path to the Perl used to run your script, if necessary.