Why can't perl locate a module that exists in @INC?

1.8k Views Asked by At

I've been running a perl script from python successfully for a while. I've just moved everything to a new computer (both are running Windows 10) and I'm running into issues.

When running the script I get the error:

Can't locate DBI.pm in @INC (you may need to install the DBI module) (@INC contains: /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl)

On the first line use DBI;.

I moved to using Perl (command line), selected the folder with the script and ran perl <filename> - same error.

DBI seems to be installed correctly in C:\Strawberry\perl\vendor\lib and that directory is in my @INC when I check via perl -V:

  @INC:
    C:/Strawberry/perl/site/lib
    C:/Strawberry/perl/vendor/lib
    C:/Strawberry/perl/lib

I've tried installing DBI again using cpan Module::DBI but I get the error:

Could not expand [Module::DBI]. Check the module name.

I've tried installing it with perl -MCPAN -e "install Bundle::DBI" but it fails with:

Test Summary Report
-------------------
t/original.t (Wstat: 0 Tests: 27 Failed: 1)
  Failed test:  26
Files=1, Tests=27,  1 wallclock secs ( 0.05 usr +  0.01 sys =  0.06 CPU)
Result: FAIL
Failed 1/1 test programs. 1/27 subtests failed.
gmake: *** [Makefile:863: test_dynamic] Error 255
  NEILB/IO-Tee-0.65.tar.gz
  C:\STRAWB~1\c\bin\gmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports NEILB/IO-Tee-0.65.tar.gz
Stopping: 'install' failed for 'IO::Tee'.

I didn't have any issues when setting things up on my previous machine (both times it has just been a vanilla install with no importing of additional modules).

I've tried reinstalling Strawberry a couple of times to no avail. I've tried installing perlbrew and ActivePerl but hit issues with both of those. I've also now exhausted Google for potential solutions.

Any ideas?


Edit:

Following the advice here I have run perl -e "use DBI;" and there is no error message which apparently means DBI is installed correctly?


Edit 2

Ok so I've managed to get things working via Perl (command line) and also via Windows cmd - it took a complete reinstall of MySQL which doesn't really make any sense but anyways. However, I still can't execute the script using Git Bash. I get the same error as always...

1

There are 1 best solutions below

3
ikegami On

[ Update: Bug fixed in IO-Tee 0.66. ]

The failing test assumes that sysread obeys the :crlf layer that's added to file handles in Windows. But it doesn't. This is a bad test, not a problem with the module. As such, since that's the only failing test, you can safely force the installation of the module using the following:

cpan -f IO::Tee

Forcing the installation of a module with failing tests is normally a bad idea because it means you're forcing the installation of a module that's likely broken. But it's ok here because it has been established that the problem is with the test, not the module itself.

I have filed a bug report with a more thorough explanation of the problem and a solution.