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

It should be easy.

Agreed, and I know issues like this can be frustrating to debug, so I hope some clarification is helpful:

the @INC is correctly updated ... That fails because cpan didn't update @INC environment correctly. ... the user environment @INC is updated by cpan

Sorry, no, because it's not cpan's job to change @INC or the environment. cpan just installs modules into the directories that are available.

installing modules as root to avoid the issue for a user is also a work-around, and not a good one

Well, if you're installing modules into the system Perl, then normally only root has access to those directories.

Here's a brief and slightly simplified overview of what's going on here:

The solution is to fix the root cause.

I hope you see now that the root cause here is the environment provided by cron.

This being Perl, there are a bunch of different solutions: a bunch of different ways to set PERL5LIB so that it's available even when scripts are run by cron (one example), other ways to set up @INC so that it always includes the directory where the modules are installed, and ways of installing modules so that perl can always find them (as I've described). So many, in fact, that I don't think listing them all here will be very helpful - each has its advantages and disadvantages, also depending on things like whether you need the modules to be available to all users or even all scripts that you want to run, and so on. So I'll just make a few suggestions of solutions (not workarounds!), and if you need more information, feel free to ask and provide more details of how you want your setup to look.

Replies are listed 'Best First'.
Re^8: Perl app won't compile /run from cron
by morgon (Priest) on May 27, 2018 at 17:16 UTC
    installing modules into the system Perl has risks
    Very true. Just try to avoid it if at all possible.

    If you can, just leave the system perl alone, install your own version via perlbrew and use paths to this version as hash-bangs in your scripts.

    Then you should have no problems running them via cron.

      Hi
      I have been using perl for about 10 years. I struck and solved the cron PATH limited environment problem years ago.
      Never had a problem running perl scripts from cron before.
      Never new about @INC and never knew about or used local::lib. Never before needed to.

      This has been a frustrating problem to solve. Now that I know what to search for, I find this is a problem shared by many others.
      I am sure it would be really helpful for others in the future to add this as a specific item in the tutorials section of this website.


      Dazz

        "This has been a frustrating problem to solve."

        The issue had been explained to you several times, and your repeated response was that this was a bug, rather than you not taking the time to understand how things work.

        "I am sure it would be really helpful for others in the future to add this as a specific item in the tutorials section of this website."

        Your contribution would be welcome. Write something up.

        Hi
        All of this was compounded by Chatterbox seemingly not working for me. I wasn't seeing the messages telling me I was posting duplicate posts, or that new replies had been posted, etc.
        When I pressed refresh to update Chatterbox, I didn't see that I had any replies. I now know that pressing refresh inadvertently generated duplicate posts. When people quite rightly complained about the duplicate posts, I couldn't see those messages either. I resorted to SuperSearch to finding replies. This appears to be because my message inbox was full.
        I have only just found the message inbox and cleared out some old messages. I note there is no link to a message inbox on the top right of the web pages, so it wasn't obvious to me that I had an inbox, and if I did, that there would be anything in it, so I had no reason to click the "Settings Nodelet>Message" link. Now Chatterbox is working I can see what's been happening.
        It was only after reading the messages that I figured out what a node reaper means and does. A reaper is a harvester so a message that says my node has been "harvested" doesn't tell me anything. NodeKiller I would have understood immediately.
        So if you have sensed a high level of frustration on my part, you'd be right. It's the reason visiting this website is the option of last resort for me. The information available from expert contributors here is fantastic. The website itself is not.

        Thank you for your tolerance and good information. I will try and stay away for as long as I can.

        Dazz