即使我已经从 cpan 和 cpanm 安装了 DateTime.pm,怎么可能找不到呢?但仍然得到它在@INC 中找不到的错误?它不是重复的,因为我不询问谁来下载 modul - 正如我所说的,我尝试从 2 个来源安装它并且我做到了,但仍然是错误Can't locate DateTime.pm in @INC。我不知道我做错了什么。
代码很简单:
#!/usr/bin/perl
use DateTime;
my $t = localtime;
my $now = DateTime->new(
year => $t->year,
month => $t->mon,
day => $t->mday,
);
print $now
和错误:
Can't locate DateTime.pm in @INC (you may need to install the DateTime module) (@INC contains:
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.28.1
/usr/local/share/perl/5.28.1
/usr/lib/x86_64-linux-gnu/perl5/5.28
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.28
/usr/share/perl/5.28
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
) at ./a line 2.
似乎我找不到 DateTime.pm 但我确实在这里:
/home/shepherd/.cpan/build/DateTime-1.51-0/blib/lib/DateTime.pm
/home/shepherd/.cpan/build/DateTime-1.51-0/lib/DateTime.pm
/home/shepherd/.cpan/build/DateTime-TimeZone-2.37-0/t/lib/T/RequireDateTime.pm
/home/shepherd/.cpanm/work/1572257193.20577/DateTime-1.51/lib/DateTime.pm
/home/shepherd/.cpanm/work/1572257193.20577/DateTime-TimeZone-2.37/t/lib/T/RequireDateTime.pm
/home/shepherd/.cpanm/work/1572257544.21848/DateTime-1.51/lib/DateTime.pm
/home/shepherd/.cpanm/work/1572257544.21848/DateTime-TimeZone-2.37/t/lib/T/RequireDateTime.pm
这到底是怎么回事?
一些可能有用的信息:
$ which cpan
/usr/bin/cpan
$ head -n 1 `which cpan`
usr/bin/perl
$ which cpanm
/usr/bin/cpanm
$ head -n 1 `which cpanm`
usr/bin/perl
$ /usr/bin/perl -V:'inst.*lib'
installarchlib='/usr/lib/x86_64-linux-gnu/perl/5.28';
installprivlib='/usr/share/perl/5.28'
installsitelib='/usr/local/share/perl/5.28.1'
installvendorlib='/usr/share/perl5'
@INC (when 'use DateTime;')
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.28.1
/usr/local/share/perl/5.28.1
/usr/lib/x86_64-linux-gnu/perl5/5.28
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.28
/usr/share/perl/5.28
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
该命令set | grep ^PERL没有任何回应,我已经尝试过set | grep -i perl,但只是在一些 if 语句中被提及,例如:if type perl &> /dev/null; then。第二个命令echo 'o conf' | cpan是这样的:Loading internal logger. Log::Log4perl recommended for better logging There seems to be running another CPAN process (pid 2023). Contacting... Other job not responding. Shall I overwrite the lockfile '/home/shepherd/.cpan/.lock'? (Y/n) [y] Ok, bye