Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Perl app won't compile /run from cron

by dazz (Beadle)
on May 24, 2018 at 11:05 UTC ( [id://1215148]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl app won't compile /run from cron
in thread Perl app won't compile /run from cron

Hi Grab is located:
darren@trackcam3:~ $ find ~/ -name Grab /home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/lib/Image/Grab /home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/blib/lib/Image/Grab /home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/blib/lib/auto/Image/G +rab /home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/blib/arch/auto/Image/ +Grab /home/darren/perl5/lib/perl5/arm-linux-gnueabihf-thread-multi-64int/au +to/Image/Grab /home/darren/perl5/lib/perl5/Image/Grab
Image::Magick is installed here:
/usr/lib/arm-linux-gnueabihf/perl5/5.24/Image/Magick /usr/lib/arm-linux-gnueabihf/perl5/5.24/auto/Image/Magick
This is a headless server so having libraries splattered around isn't helpful. Looking back at my notes, CPAN installed the modules in my home dir. The Ubuntu packages were installed in /usr.

Dazz

Replies are listed 'Best First'.
Re^3: Perl app won't compile /run from cron
by marto (Cardinal) on May 24, 2018 at 11:19 UTC

    "This is a headless server so having libraries splattered around isn't helpful"

    Then don't do that. If you are using the system perl and a package is available in apt, use that, otherwise you need to install things in the right place (sudo cpanm Image::Grab), or (as detailed in other replies you already have) specify the correct paths for your cron jobs for where you have installed things.

      Hi
      I didn't intentionally install the modules in the home directory but even if I did, I am trying to run a cron perl script as user (not root). So perl should have configured itself to do that by default.
      I have just run  sudo cpan BLOB, the other module not found. It is installed in /usr/local/share/perl/5.24.1/BLOB
      Installing the modules as root has fixed the problem. The perl compiler can now find the modules by default.

      So modules installed with CPAN in the home user directory aren't found when the script is run as user by cron. That's a bug.


      Dazz

        That's a bug.

        No it is not a bug, cron was designed that way

        cron is designed to set up a minimal environment when it starts a cron job. It is not a login session so it does not add any environment settings specified via login-semantics such as found in rc files. it is up to you to set them up.

        The Cron Environment and Cron Job Failures discusses this in more depth.

        "I didn't intentionally install the modules in the home directory but even if I did, I am trying to run a cron perl script as user (not root). So perl should have configured itself to do that by default. "

        This would be undesirable behaviour. Users without appropriate permissions should not be able to install things system wide. Fortunately for us as users the tools provide this useful feature under the hood to take care of this. If you read cpanm and local::lib you'll understand what they do.

        "So modules installed with CPAN in the home user directory aren't found when the script is run as user by cron. That's a bug."

        I appreciate why you may think so, but this is not the case, it isn't a bug. If you take a step back and think about this from the perspective of security and a multi user system, this is how it's supposed to work. The alternative options described in other responses would also have worked.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1215148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found