Perl/cpan: 无法找到 JSON/Parse.pm @INC

huangapple go评论61阅读模式
英文:

Perl/cpan: Can't locate JSON/Parse.pm @INC

问题

我正在运行 CentOS 7。

我已经通过 cpan 安装了 JSON::Parse,但出现了错误。

无法在 @INC 中定位 JSON/Parse.pm (@INC 包含:
/home/truckassist/modules
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5 .)

当运行 cpan JSON::Parse 时,我得到了以下结果:JSON::Parse 已经是最新版本 (0.62)

到目前为止,我尝试了以下方法...

perl -e "print qq(@INC)"
输出:

/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

还有:

find /root/perl5 -iname '*json*'

输出:

/root/perl5/bin/json_pp
/root/perl5/bin/validjson
/root/perl5/lib/perl5/x86_64-linux-thread-multi/auto/JSON
/root/perl5/lib/perl5/x86_64-linux-thread-multi/auto/Cpanel/JSON
/root/perl5/lib/perl5/x86_64-linux-thread-multi/Cpanel/JSON
/root/perl5/lib/perl5/x86_64-linux-thread-multi/JSON
/root/perl5/lib/perl5/JSON
/root/perl5/lib/perl5/JSON.pm
/root/perl5/man/man1/cpanel_json_xs.1
/root/perl5/man/man1/json_pp.1
/root/perl5/man/man3/JSON::PP.3pm
/root/perl5/man/man3/JSON::PP::Boolean.3pm
/root/perl5/man/man3/JSON.3pm
/root/perl5/man/man3/JSON::backportPP.3pm
/root/perl5/man/man3/JSON::backportPP::Boolean.3pm
/root/perl5/man/man3/JSON::backportPP::Compat5005.3pm
/root/perl5/man/man3/JSON::backportPP::Compat5006.3pm
/root/perl5/man/man3/JSON::Parse.3pm
/root/perl5/man/man3/Cpanel::JSON::XS.3pm
/root/perl5/man/man3/Cpanel::JSON::XS::Boolean.3pm
/root/perl5/man/man3/Cpanel::JSON::XS::Type.3pm
/root/perl5/man/man3/JSON::MaybeXS.3pm
/root/perl5/man/man3/JSON::Tokenize.3pm
/root/perl5/man/man3/JSON::Whitespace.3pm

我只能假设它正在查看错误的 cpan/perl 目录。

是否有人可以协助或提供一些方向?

英文:

I'm running on CentOS 7.

I've installed JSON::Parse via cpan but getting the error.

Can't locate JSON/Parse.pm in @INC (@INC contains: 
/home/truckassist/modules 
/usr/local/lib64/perl5 
/usr/local/share/perl5 
/usr/lib64/perl5/vendor_perl 
/usr/share/perl5/vendor_perl 
/usr/lib64/perl5 
/usr/share/perl5 .)

When running cpan JSON::Parse I get the following: JSON::Parse is up to date (0.62)

I've tried the following so far...

perl -e "print qq(@INC)"

Output:

/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

Also:

find /root/perl5 -iname '*json*'

Output:

/root/perl5/bin/cpanel_json_xs
/root/perl5/bin/json_pp
/root/perl5/bin/validjson
/root/perl5/lib/perl5/x86_64-linux-thread-multi/auto/JSON
/root/perl5/lib/perl5/x86_64-linux-thread-multi/auto/Cpanel/JSON
/root/perl5/lib/perl5/x86_64-linux-thread-multi/Cpanel/JSON
/root/perl5/lib/perl5/x86_64-linux-thread-multi/JSON
/root/perl5/lib/perl5/JSON
/root/perl5/lib/perl5/JSON.pm
/root/perl5/man/man1/cpanel_json_xs.1
/root/perl5/man/man1/json_pp.1
/root/perl5/man/man3/JSON::PP.3pm
/root/perl5/man/man3/JSON::PP::Boolean.3pm
/root/perl5/man/man3/JSON.3pm
/root/perl5/man/man3/JSON::backportPP.3pm
/root/perl5/man/man3/JSON::backportPP::Boolean.3pm
/root/perl5/man/man3/JSON::backportPP::Compat5005.3pm
/root/perl5/man/man3/JSON::backportPP::Compat5006.3pm
/root/perl5/man/man3/JSON::Parse.3pm
/root/perl5/man/man3/Cpanel::JSON::XS.3pm
/root/perl5/man/man3/Cpanel::JSON::XS::Boolean.3pm
/root/perl5/man/man3/Cpanel::JSON::XS::Type.3pm
/root/perl5/man/man3/JSON::MaybeXS.3pm
/root/perl5/man/man3/JSON::Tokenize.3pm
/root/perl5/man/man3/JSON::Whitespace.3pm

I can only assume it's looking at the incorrect cpan/perl directory.

Can anyone please assist or provide some direction?

答案1

得分: 6

你将模块安装在非标准目录 (/root/perl5/lib/perl5/x86_64-linux-thread-multi),[1] 且你没有告诉 perl 关于它的存在[2],或者你没有足够的权限来访问它。

确保其他用户具备访问 /root/perl5 及其内容所需的权限。

要通知 perl 在哪里查找这些模块,你可以使用

export PERL5LIB=/root/perl5/lib/perl5

或者,停止在安装给机器上的所有人时将模块安装在不寻常的位置。

在以 root 身份时取消设置 PERL_MB_OPTPERL_MM_OPT(以及 PERL5LIB),然后重新安装该模块。你可能想要摆脱 /root/perl5 以避免混淆。


  1. 你作为 root 使用 local::lib,为 root 安装模块 "仅限 root"。
  2. 除非以 root 身份运行,这就是为什么 cpan 在以 root 身份运行时找到它的原因。
  3. 例如,不要在以 root 身份时使用 local::lib。
英文:

You installed the module in a non-standard directory (/root/perl5/lib/perl5/x86_64-linux-thread-multi),<sup>[1]</sup> and you didn't tell perl about it<sup>[2]</sup>, or you don't have sufficient permissions to access it.

Make sure other users have the permissions needed to access /root/perl5 and its contents.

And to let perl know where the find the modules, you could use

export PERL5LIB=/root/perl5/lib/perl5

Alternatively, stop installing the module in an unusual location when installing for everyone on the machine.

Unset PERL_MB_OPT and PERL_MM_OPT (and PERL5LIB) when root,<sup>[3]</sup> then re-install the module. You might want to get rid of /root/perl5 to avoid confusion.


  1. You are using local::lib as root, installing modules "just for root".
  2. Except when running as root, which is why cpan finds it when root.
  3. For example, by not using local::lib as root.

huangapple
  • 本文由 发表于 2023年6月19日 17:01:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76505135.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定