Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

what should be in PERL5LIB after installing from source the 5.40.1 version on MacOS (am64)

by kwolcott (Acolyte)
on Feb 22, 2025 at 04:28 UTC ( [id://11164056]=perlquestion: print w/replies, xml ) Need Help??

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

I'm really confused and frustrated about how to get my PERL5LIB environment variable set correctly.

I'm on MacOS Sequoia, aarch64, running zsh, installed Perl 5.40.1 from source, into the /opt/perl_5.40.1 directory.

I already have a Perl 5.38.2, also built from source, located in the /opt/perl directory.

I have a MacPorts version of Perl installed (5.34.3). I removed an additional MacPorts Perl version 5.38.3 that I had installed recently.

I was reading in the Programming Perl book about PERL5LIB...I don't understand the order of the paths that should be in the PERL5LIB.

I've installed MANY Perl modules from CPAN using cpanm, specifying -L path respective to each version of Perl.

I have a section in my ~/.zshrc for Perl that looks like this:

use_perl_534() { export PATH="/opt/local/bin:$PATH" # export PERL5LIB="/opt/local/lib/perl5/5.34/site_perl:/opt/local/lib +/perl5/5.34/lib:$PERL5LIB" PERL5LIB="/opt/local/lib/perl5:/opt/local/lib/perl5/5.34:/opt/local/ +lib/perl5/5.34/darwin-thread-multi-2level:/opt/local/lib/perl5/vendor +_perl/5.34:/opt/local/lib/perl5/vendor_perl/5.34/darwin-thread-multi- +2level:$PERL5LIB" echo "Using Perl 5.34" } # /opt/perl/lib/perl5/darwin-2level/ntheory.pm # /opt/perl/lib/lib/perl5/darwin-2level/ntheory.pm use_perl_538() { export PATH="/opt/perl/bin:$PATH" # export PERL5LIB="/opt/local/lib/perl5/5.38/site_perl:/opt/local/lib +/perl5/5.38/lib:$PERL5LIB" PERL5LIB="/opt/perl/lib/perl5:/opt/perl/lib/perl5/darwin-2level:/opt +/perl/lib/perl5/darwin-2level/.meta:/opt/perl/lib/5.38.2:/opt/perl/li +b/5.38.2/darwin-2level:/opt/perl/lib/site_perl/5.38.2:/opt/perl/lib/s +ite_perl/5.38.2/darwin-2level:/opt/perl/lib/lib:/opt/perl/lib/lib/per +l5:/opt/perl/lib/lib/perl5/darwin-2level:/opt/perl/lib/lib/perl5/darw +in-2level/.meta:$PERL5LIB" echo "Using Perl 5.38" } # /opt/perl_5.40.1/lib/lib/perl5/local # /opt/perl_5.40.1/lib/lib/perl5/darwin-thread-multi-2level/auto/local use_perl_540() { export PATH="/opt/perl_5.40.1/bin:$PATH" # export PERL5LIB="/opt/perl_5.40.1/lib/perl5/site_perl:/opt/perl_5.4 +0.1/lib/perl5:$PERL5LIB" PERL5LIB="/opt/perl_5.40.1/lib:/opt/perl_5.40.1/lib/5.40.1:/opt/perl +_5.40.1/lib/5.40.1/darwin-2level:/opt/perl_5.40.1/lib/site_p erl:/opt/perl_5.40.1/lib/site_perl/5.40.1:/opt/perl_5.40.1/lib/site_pe +rl/5.40.1/darwin-2level:/opt/perl_5.40.1/lib/lib:/opt/perl_5 .40.1/lib/lib/perl5:/opt/perl_5.40.1/lib/lib/perl5/darwin-thread-multi +-2level:/opt/perl_5.40.1/lib/lib/perl5/darwin-thread-multi-2 level/.meta:$PERL5LIB" echo "Using Perl 5.40.1" }

I'm not using homebrew and I'm not using perlbrew.

I was using Sidef (installing manually as a standalone executable, not as a Perl Module) for some while, then things went bonkers when I installed Perl 5.38.3 from MacPorts (I think). Now Sidef fails, and many Perl programs fail that require modules (some work, some fail).

./wagstaff_primes.pl Can't locate local/lib.pm in @INC (you may need to install the local:: +lib module) (@INC entries checked: /opt/perl_5.40.1/lib/site_perl/5.4 +0.1/darwin-2level /opt/perl_5.40.1/lib/site_perl/5.40.1 /opt/perl_5.4 +0.1/lib/5.40.1/darwin-2level /opt/perl_5.40.1/lib/5.40.1) at ./wagsta +ff_primes.pl line 4. BEGIN failed--compilation aborted at ./wagstaff_primes.pl line 4.

The aforementioned is a script from Rosetta Code.

find /opt/perl_5.40.1/lib -type f -name lib.pm /opt/perl_5.40.1/lib/5.40.1/darwin-2level/lib.pm /opt/perl_5.40.1/lib/lib/perl5/local/lib.pm
  • Comment on what should be in PERL5LIB after installing from source the 5.40.1 version on MacOS (am64)
  • Select or Download Code

Replies are listed 'Best First'.
Re: what should be in PERL5LIB after installing from source the 5.40.1 version on MacOS (am64)
by haj (Vicar) on Feb 22, 2025 at 10:36 UTC

    If you install Perl by compiling from source, beginning with the Configure script, then you do not need anything in PERL5LIB. This script creates a makefile which contains all the information the Perl executable needs: The executable itself knows where to find the core libraries.

    To debug your situation, I suggest that you deactivate all settings of PERL5LIB and then examine @INC for all your Perl executables:

    perl -E 'say for @INC'

    In your listings there are some occurrences of lib/lib/ which seems to indicate that modules have been installed into wrong places.

      Thank you.

      I did the following:

      unset PERL5LIB

      for each version of Perl (5.38.2, 5.34.3, 5.40.1)

      perl -E 'say for @INC'

      The paths displayed then became part of my PERL5LIB, for each version.

      Regarding the "/lib/lib" path, I already noticed that having that was very odd and most likely incorrect. But I'm sure that it results from my (most likely incorrect) understanding of how to install Perl modules for each version of Perl. This is the method that I'm currently using; please correct me if I'm doing it wrong:

      /opt/perl/bin/cpanm -L /opt/perl/lib install "module"

      /opt/perl_5.40.1/bin/cpanm -L /opt/perl_5.40.1/lib install "module"

      I try not to install Perl modules where my MacPorts Perl is (/opt/local/lib/perl) as that is where MacPorts writes things...

      So if I uninstall all Perl modules that appear under a "lib/lib" path, and reinstall them, what syntax do I use to make sure that when I reinstall, the modules are placed in the correct location?

      Thank you.

        The paths displayed then became part of my PERL5LIB, for each version.

        But why? These are the paths Perl already knows about, there's no need to list them in PERL5LIB!

        If your cpanm programs have been installed properly, then each of them should be able to install into suitable locations without specifing any -L directory at all. If you run:

        cpanm --version

        ...then each cpanm will tell you which version of Perl it is running, where it is about to install, and where it is looking for libraries (should be mostly the same as where it is about to install, with exception of cpanm's own FatPacked stuff). These should be different for each cpanm, and different from where your MacPorts Perl is installing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11164056]
Approved by Corion
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2025-03-26 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (67 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.