prgrm
prgrm

Reputation: 3833

Why do I get "Can't locate Sub/Identify.pm in @INC" when I use the DateTime module even though I installed the perl-DateTime RPM?

I am trying to use the module DateTime in CentOS so I installed it like this:

yum install perl-DateTime

and then added use DateTime to my script, but I get this error:

Can't locate Sub/Identify.pm in @INC (@INC contains:
/root/perl5/lib/perl5/5.16.3/x86_64-linux-thread-multi
/root/perl5/lib/perl5/5.16.3
/root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5
/usr/local/lib64/perl5 /usr/local/share/perl5
/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl
/usr/lib64/perl5 /usr/share/perl5 .) at
/root/perl5/lib/perl5/namespace/autoclean.pm line 200. Compilation
failed in require at /root/perl5/lib/perl5/DateTime/Locale.pm line 11.
BEGIN failed--compilation aborted at
/root/perl5/lib/perl5/DateTime/Locale.pm line 11. Compilation failed
in require at /usr/lib64/perl5/vendor_perl/DateTime.pm line 45. BEGIN
failed--compilation aborted at
/usr/lib64/perl5/vendor_perl/DateTime.pm line 45. Compilation failed
in require at myscript.pl line 8. BEGIN failed--compilation aborted
at myscript.pl line 8.

I have no idea what's going on. I already installed several packages through the CPAN. This is the first time I've tried with yum install and it doesn't work. Any ideas?

Upvotes: 1

Views: 2799

Answers (1)

ThisSuitIsBlackNot
ThisSuitIsBlackNot

Reputation: 24073

TL;DR

This is why it's a bad idea to mix modules installed via a package manager and via CPAN.


It looks like you installed DateTime with yum, but DateTime::Locale with CPAN. You can see this by following the dependency chain in your error message:

/root/perl5/lib/perl5/namespace/autoclean.pm --> CPAN
/root/perl5/lib/perl5/DateTime/Locale.pm     --> CPAN
/usr/lib64/perl5/vendor_perl/DateTime.pm     --> yum

The newest version of namespace::autoclean depends on Sub::Identify, which seems to be missing from @INC.

So did yum install a package with missing dependencies? Nope, it installed an older version of DateTime::Locale, when namespace::autoclean wasn't a dependency:

$ cpan -D DateTime::Locale | grep -oP '[\d.]+(?=\s+up)'     # newest version
1.14
$ yum info perl-DateTime-Locale | grep -oP 'Version\D+\K.+' # yum version
0.45
$ rpm -q --requires perl-DateTime-Locale | grep autoclean
$

But since you put /root/perl5/lib/perl5 before the system perl directories in @INC, you're loading the version installed by CPAN, which does need namespace::autoclean and Sub::Identify. Of course, yum has no way to know that.

I'm not sure why Sub::Identify is missing...you may have deleted it, or it may simply be installed outside of @INC. You could try to re-install it with CPAN, but it would be better to:

  • remove /root/perl5/* from @INC and only install modules in the system perl with yum
  • use perlbrew or plenv to create your own local installation of perl and install modules with cpan

Upvotes: 3

Related Questions