sidmuchrock has asked for the wisdom of the Perl Monks concerning the following question:

So I was a perl 4 person for years, played in 5, scared of 6. Went to do something smarter than the old way today with dates. Old way is I would have created a @months=('January', etc.) Not even a qw as I'm that old. Anyway decided I'd go a bit more modern and use Date::Manip.pm but its not there. Okay add it. Wait strict isn't there?! My @INC doesn't seem to be playing right. Thoughts? Lemme add more danger. Strict was there earlier today as I used cpan to add DateTime. but it wouldn't install unless I used sudo cspan DateTime. It/I borked my @INC somehow. Wise Monks, what you got?

[SiDMBP2:~] urinine% perl dog2.pl Can't locate Date/Manip.pm: Permission denied at dog2.pl line 1. BEGIN failed--compilation aborted at dog2.pl line 1. [SiDMBP2:~] urinine% locate Manip.pm [SiDMBP2:~] urinine% cpan Manip.pm Can't locate strict.pm: Permission denied at /usr/bin/cpan5.18 line +7. BEGIN failed--compilation aborted at /usr/bin/cpan5.18 line 7. [SiDMBP2:~] urinine% locate strict.pm /System/Library/Perl/5.18/strict.pm [SiDMBP2:~] urinine% perl -e 'print(join("\n", @INC))' /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.4 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .

Replies are listed 'Best First'.
Re: Issue with @INC
by dave_the_m (Monsignor) on Oct 14, 2019 at 18:16 UTC
    Something in your INC path is missing the correct permissions for your user. For security reasons perl stops scanning @INC at that point rather than processing any remaining directories. So you'll most likely find that strict.pm is indeed installed, but permissions have been screwed. This often happens when the PERL5LIB env var is set and is pointing to somewhere weird like /root/lib

    Dave.

      Oh yes, you're entirely right. I tested with

      [SiDMBP2:~] urinine% perl dog.pl Can't locate feature.pm: Permission denied at dog.pl line 1. BEGIN failed--compilation aborted at dog.pl line 1. [SiDMBP2:~] urinine% sudo perl dog.pl Hello World Wednesday

      So it IS permissions. Okay what's the issue:

      [SiDMBP2:~] urinine% perl -e 'print(join("\n", @INC))' | xargs ls -ld ls: /Library/Perl/Updates/5.18.4: Permission denied ls: /Network/Library/Perl/5.18: No such file or directory ls: /Network/Library/Perl/5.18/darwin-thread-multi-2level: No such fil +e or directory drwxr-xr-x+ 55 urinine staff 1760 Oct 14 14:32 . drwxr-xr-x 25 root wheel 800 Oct 14 11:08 /Library/Perl/5.18 drwxr-xr-x 11 root wheel 352 Oct 14 11:08 /Library/Perl/5.18/d +arwin-thread-multi-2level drwxr-xr-x 130 root wheel 4160 Jul 24 08:26 /System/Library/Perl +/5.18 drwxr-xr-x 56 root wheel 1792 Jul 24 08:26 /System/Library/Perl +/5.18/darwin-thread-multi-2level drwxr-xr-x 109 root wheel 3488 Aug 17 2018 /System/Library/Perl +/Extras/5.18 drwxr-xr-x 72 root wheel 2304 Sep 21 2018 /System/Library/Perl +/Extras/5.18/darwin-thread-multi-2level

      So what's in that first directory

      [SiDMBP2:/Library/Perl] urinine% sudo ls -l /Library/Perl/Updates/5.18 +.4 total 0 drwx------ 3 root wheel 96 Oct 14 11:03 darwin-thread-multi-2level [SiDMBP2:/Library/Perl] urinine% sudo ls -l /Library/Perl/Updates/5.18 +.4/darwin-thread-multi-2level total 16 -rw------- 1 root wheel 7027 Oct 14 11:08 perllocal.pod

      Yep. Can't access those. So can I pull that out of my @INC somehow, or should I just blast some ugly overblown permissions over the directories?

        Well I'm not familiar with macs, but assuming all those paths are hard-coded into your perl binary (you can check with perl -V) then it seems most likely that the permissions on the directory is the thing needing fixing.

        Dave.

        Those directories hold the installed Perl system and should be 0755 for directories and 0644 for files. I believe that chown a+rX -R `perl -e 'print(join("\n", @INC))'` at a root prompt should fix it. The root cause was probably a bad umask value while updating Perl modules.

        Those permissions are not overblown at all — most of the system should be accessible to all users.

Re: Issue with @INC
by marto (Cardinal) on Oct 14, 2019 at 18:11 UTC

      That was indeed my first stop. However I'm not making the connection. I've got no PERL5LIB.

      [SiDMBP2:~] urinine% echo $PERL5LIB PERL5LIB: Undefined variable.

      I'm just not sure where the @INC gets set, and the examples on that site such as:

      $ PERL5LIB=/tmp/foo perl -M-lib=/tmp/foo -le 'print for @INC'

      will remove the offender temporarily, but 5 seconds later a print of @INC shows its back.

      I appreciate your help. Thanks.

        I've not used MacOS since it was called OS X, this is perhaps out of date, my gut says it probably is. For your perl related problem I'd suggest leaving the system perl alone, install your own perl elsewhere on the system. perlbrew or just INSTALL giving it a prefix.

Re: Issue with @INC
by 1nickt (Canon) on Oct 14, 2019 at 20:11 UTC

    Hi, just to reiterate what marto said, don't use the system perl on a Mac. Don't install modules for it, don't write scripts that use it ... it's not for you. It is for the system.

    Instead, install perlbrew, use that to install a modern Perl version, pay attention to the trivial setup you need to do (add a line to your .bash_profile), `perlbrew switch` to the new perl, and you are able to install anything you like as the logged in user, switching among as many Perl versions as you'd like to play with.

    Do it today!

    Hope this helps!


    The way forward always starts with a minimal test.

      So, sort of related https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes, looks like perl doesn't fit in with the future of MacOS out of the box at least:

      "Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app."

Re: Issue with @INC
by holli (Abbot) on Oct 14, 2019 at 17:09 UTC
    The language Raku (formerly known as Perl6) comes with a date class built in. And there is no need to be scared. You can immedeatly understand what this does:
    constant \SUNDAY = 7; .say for ( 2019 .. 2100 ) .map( { DateTime.new( :$^year, month => 12, day => 25 ) }) .grep( { .day-of-week == SUNDAY }) .map( { .year }) ;
    I am just posting this because you mentioned 6, it is not related to the problem (obviously).


    holli

    You can lead your users to water, but alas, you cannot drown them.
Re: Issue with @INC
by karlgoethebier (Abbot) on Oct 14, 2019 at 17:38 UTC

    urinine is a strange name for a user even on a Mac. I guess he isn‘t root. This fact might explain some of the strange things that happen to him. You may take a look at perlbrew to leave the Perl on his Mac untouched. Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help