Search code examples
linuxperlcentoscentos7

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


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?


Solution

  • You installed the module in a non-standard directory (/root/perl5/lib/perl5/x86_64-linux-thread-multi),[1] and you didn't tell perl about it[2], 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,[3] 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.