t-rex has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am trying to install YAML::XS package on of the machine where I use the command:

curl -L http://cpanmin.us | perl – App::cpanminus and then cpanm YAML::XS

But when I run my file it shows me error

Can't locate YAML/XS.pm in @INC (@INC contains: /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 urs.pl line 4. BEGIN failed--compilation aborted at urs.pl line 4.

I am aware of the fact that my @INC doesn’t have the path wher my modules are installed ( I am not a sudo here in prev machines I was so no such problem I faced) , please let me know how to solve this error. I can’t use :

 use lib ‘’

because of portability as my script is going to work on multiple machines.

Replies are listed 'Best First'.
Re: Module not installed in @INC
by LanX (Saint) on Aug 12, 2016 at 12:21 UTC
    As Hippo already pointed out (twice) you need to set PERL5LIB accordingly for the users of your script.

    You can set the environment variable in the .profile or .bashrc or whatever of the users of your script. Otherwise talk to the Admin.

    If this fails, you still have the option to use perlbrew for a private Perl installation. (different machines might mean different perl versions, see also marto's remark according to fatpacker to have all dependencies included)

    > use lib

    > because of portability as my script is going to work on multiple machines.

    And you can dynamically adjust @INC according to $ENV{HOST} in a BEGIN block.

    update

    see also using my module.pm in different directory error

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re: Module not installed in @INC
by marto (Cardinal) on Aug 12, 2016 at 10:45 UTC

    "I am aware of the fact that my @INC doesn’t have the path wher my modules are installed"

    "because of portability as my script is going to work on multiple machines."

    Why not package your script to include all modules/dependencies? See pp, App::FatPacker.

Re: Module not installed in @INC
by hippo (Archbishop) on Aug 12, 2016 at 10:51 UTC

      hello, as this si leagcy code i can't change such things, and also since this working on most machines except for those where i don't have the sudo access. so i am looking for some way where i can include these packages in my @INC. What i have come across is that CPAN.pm , i couldn't find it to change some conf

        As you seem to be unwilling to change %ENV, maybe it's now a good time to simply request sudo access on the problematic machines so you can make the necessary changes there?