in reply to @INC error

It's true that /usr/local/share/perl5/Mail is the location of Mailer.pm, but Perl isn't looking for Mailer.pm; Perl is looking for Mail/Mailer.pm. /usr/local/share/perl5 needs be added to @INC.

Replies are listed 'Best First'.
Re^2: @INC error
by worstead (Acolyte) on Jan 17, 2020 at 18:51 UTC
    Tried that. "/usr/local/share/perl5/Mail" there but still get same error.
    melisa:~/CRON$ ./print-INC.pl /home/jrayner/perl5/lib/perl5/x86_64-linux-thread-multi /home/jrayner/perl5/lib/perl5 /home/jrayner/perl5/lib/perl5/x86_64-linux-thread-multi /home/jrayner/perl5/lib/perl5 /home/jrayner/perl5/lib/perl5/x86_64-linux-thread-multi /home/jrayner/perl5/lib/perl5 /usr/local/share/perl5/Mail /usr/local/lib64/perl5/5.30 /usr/local/share/perl5/5.30 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5
    error
    Can't locate Mail/Mailer.pm in @INC (you may need to install the Mail: +:Mailer module) (@INC contains: /usr/local/lib64/perl5/5.30 /usr/loca +l/share/perl5/5.30 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vend +or_perl /usr/lib64/perl5 /usr/share/perl5) at /home/jrayner/CRON/emai +l-reminder-2.0.pl line 62. BEGIN failed--compilation aborted at /home/jrayner/CRON/email-reminder +-2.0.pl line 62.
    The program "email-reminder-2.0.pl" appears to run correctly when called independently but not when called by cron.
      Tried that.

      I think it'd be best if you showed us exactly what you tried, because the output you're showing here just shows that some of the entries in @INC got duplicated, not that the path /usr/local/share/perl5 got added to @INC like we suggested. And as I said, in cron, you'll have to set up the environment variables yourself. If you could explain more about your setup (like whether you're actually using local::lib or not, and how the module ended up where it did, what commands you're actually trying, etc.), we could be of more help.

      The program "email-reminder-2.0.pl" appears to run correctly when called independently but not when called by cron.

      It therefore seems that a different @INC is being used when cron runs the script.
      The error message plainly states that @INC is:
      /usr/local/lib64/perl5/5.30 /usr/local/share/perl5/5.30 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5
      If /usr/local/share/perl5/Mail/Mailer.pm exists, then @INC needs to include /usr/local/share/perl5.
      But /usr/local/share/perl5 is not one of the locations specified in @INC when cron runs the script.

      Cheers,
      Rob

      huh, /usr/local/share/perl5 is still not in @INC. (No idea what the first list you posted is, but it's not in that either.)

      Tried that. "/usr/local/share/perl5/Mail" there but still get same error.

      It doesn't look like it


      melisa:~/CRON$ ./print-INC.pl
      /home/jrayner/perl5/lib/perl5/x86_64-linux-thread-multi
      /home/jrayner/perl5/lib/perl5
      /home/jrayner/perl5/lib/perl5/x86_64-linux-thread-multi
      /home/jrayner/perl5/lib/perl5
      /home/jrayner/perl5/lib/perl5/x86_64-linux-thread-multi
      /home/jrayner/perl5/lib/perl5
      /usr/local/share/perl5/Mail
      /usr/local/lib64/perl5/5.30
      /usr/local/share/perl5/5.30
      /usr/lib64/perl5/vendor_perl
      /usr/share/perl5/vendor_perl
      /usr/lib64/perl5
      /usr/share/perl5

      ##</code><code>##

      Can't locate Mail/Mailer.pm in @INC (you may need to install the Mail::Mailer module) (@INC contains: /usr/local/lib64/perl5/5.30 /usr/local/share/perl5/5.30 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /home/jrayner/CRON/email-reminder-2.0.pl line 62.
      BEGIN failed--compilation aborted at /home/jrayner/CRON/email-reminder-2.0.pl line 62.