HostOnNet Blog

Can’t locate DBI.pm in @INC Perl Script Error

Today after FreeBSD server upgrade with portupgrade and freebsd-update, i started getting following error on a CGI script that use MySQL database.


Can’t locate DBI.pm in @INC
(@INC contains: /usr/local/flashcp/
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach
/usr/local/lib/perl5/5.8.8 .)
at /home/free/cgi-bin/index.cgi line 8.
BEGIN failed–compilation aborted

This error is due to Perl module DBI is missing, to install it, i loged in to server and run cpan, cpanel allow you to install Perl modules.


server22# cpan
cpan> install DBI
Running install for module DBI
Running make for T/TI/TIMB/DBI-1.50.tar.gz
LWP not available
Fetching with Net::FTP:
DBI-1.50.tar.gz
CPAN: Digest::MD5 loaded ok
LWP not available
Fetching with Net::FTP:

FreeBSD: Registering installation in the package database
Appending installation info to /usr/local/lib/perl5/5.8.8/mach/perllocal.pod
/usr/bin/make install — OK


cpan> exit
Terminal does not support GetHistory.
Lockfile removed.
server22#

after installation type “exit” to exit cpan shell. AFter installing DBI, i refreshed the CGI script, the error is gone, now i start getting different error

install_driver(mysql) failed:
Can’t locate DBD/mysql.pm in @INC
(@INC contains: /usr/local/flashcp/
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach
/usr/local/lib/perl5/5.8.8 .) at (eval 8) line 3.
Perhaps the DBD::mysql perl module hasn’t been fully installed,
or perhaps the capitalisation of ‘mysql’ isn’t right.
Available drivers: DBM, ExampleP, File, Proxy, Sponge.
at /home/free/cgi-bin/index.cgi line 16

To fix the problem, need to install DBD::mysql module, so back to cpan

install DBD::mysql did not worked, this is because it try to connect MySQL database for testing, but MySQL login with out password is disabled in the server. So we have to do force install

server22# cpan
Terminal does not support AddHistory.


cpan shell — CPAN exploration and modules installation (v1.7602)
ReadLine support available (try ‘install Bundle::CPAN’)


cpan> force install DBD::mysql

/usr/bin/make install — OK

cpan> exit
Terminal does not support GetHistory.
Lockfile removed.
server22#

After installing DBD::mysql the perl script start working.


Posted in Uncategorized. Bookmark the permalink.

  • Anonymous

    Thankyou so much for posting this! Was exactly what I was having trouble with and the fix was exactly the same

  • thanks! have been looking all around for this solution!

  • web host

    I tired this and I still get this error over and over:

    Can’t locate Cpanel/Auth/Digest/DB.pm in @INC (@INC contains: /usr/local/cpanel /usr/local/lib/perl5/5.8.8/i686-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/i686-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl .) at /usr/local/cpanel/scripts/pkgacct.dwhs9.dwhs.net line 26.
    BEGIN failed–compilation aborted at /usr/local/cpanel/scripts/pkgacct.dwhs9.dwhs.net line 26.

    It was transferring fine and this just stopped and now ever transfer gives this error.

  • Since this is cpanel server, try running

    /scripts/checkperlmodules