Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Why is lib/perl5 not added to INC for perls installed using perlbrew

by kcott (Archbishop)
on Sep 11, 2020 at 13:39 UTC ( [id://11121614]=note: print w/replies, xml ) Need Help??


in reply to Why is lib/perl5 not added to INC for perls installed using perlbrew

G'day areldy_exten,

Welcome to the Monastery.

I also have Perl 5.32.0 installed using Perlbrew. From the description of your setup, mine seems to be identical; of course, mine may differ from yours in areas that you haven't mentioned.

$ perlbrew list * perl-5.32.0 perl-5.30.0 $ which perl /home/ken/perl5/perlbrew/perls/perl-5.32.0/bin/perl $ echo $PERLBREW_ROOT /home/ken/perl5/perlbrew $ $PERLBREW_ROOT/perls/perl-5.32.0/bin/perl -V Summary of my perl5 (revision 5 version 32 subversion 0) configuration +: ... @INC: /home/ken/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/cy +gwin-thread-multi /home/ken/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0 /home/ken/perl5/perlbrew/perls/perl-5.32.0/lib/5.32.0/cygwin-threa +d-multi /home/ken/perl5/perlbrew/perls/perl-5.32.0/lib/5.32.0 $ ls -l $PERLBREW_ROOT/perls/perl-5.32.0/lib/perl5 ls: cannot access '/home/ken/perl5/perlbrew/perls/perl-5.32.0/lib/perl +5': No such file or directory
"Why isn't this included automatically in the @INC?"

Short answer: because it doesn't exist.

Longer answer. I've been using Perlbrew for a very long time, certainly more than a decade, and I don't recall $PERLBREW_ROOT/perls/<install-name>/lib/perl5 ever being a standard Perlbrew directory. This would be why such a path would not be automatically added to @INC.

I'm not a user of cpanm, I use cpan. As such, I'm not in any position to comment on your use of cpanm beyond suggesting that you check that you are using it correctly. I know cpanm is widely used: if you have questions about that, you can definitely get help about it here.

If you have modules installed in non-standard locations, consider using PERL5LIB (see "perlrun: ENVIRONMENT") or use the lib pragma. There are other ways of dealing with this but that's probably jumping the gun and heading off-topic for the current issue.

Minor in-joke for anyone who recalls "Re^4: [OT] 'perl' is not the 'perl' reported by 'which perl'": yes, I did remember type but thought which was more appropriate here. However, just for completeness:

$ type perl perl is /home/ken/perl5/perlbrew/perls/perl-5.32.0/bin/perl

— Ken

Replies are listed 'Best First'.
Re^2: Why is lib/perl5 not added to INC for perls installed using perlbrew
by tobyink (Canon) on Sep 11, 2020 at 15:50 UTC

    "I've been using Perlbrew for a very long time, certainly more than a decade, and I don't recall $PERLBREW_ROOT/perls/<install-name>/lib/perl5 ever being a standard Perlbrew directory."

    None of my perlbrew installations have such a directory either. And I do use cpanm.

      Thank you kcott and tobyinky for the replies.

      My purpose is to install a self-contained perl and a collection of modules all together.
      Such that I can have my scripts work seamlessly by just pointing the shebang to the perl bin.
      E.g.  $PERLBREW_ROOT/perls/perl-5.32.0/bin/perl in this case.

      As I mentioned in my post I installed the modules by doing
      cd $PERLBREW_ROOT/perls/perl-5.32.0 cpanm -L . MODULE
      The cpanm is localed at $PERLBREW_ROOT/bin/cpanm
      This has resulted in the following tree (truncated):
      perls \-- perl-5.32.0/ |-- bin/ | |-- cpan* | |-- perl* | |-- perl5.32.0* | \-- zipdetails* \-- lib/ |-- 5.32.0/ | |-- AnyDBM_File.pm | |-- App/ | |-- x86_64-linux-thread-multi-ld/ | \-- XSLoader.pm |-- perl5/ | |-- Alien/ | |-- alienfile.pm | |-- x86_64-linux-thread-multi-ld/ | \-- XML/ \-- site_perl/ \-- 5.32.0/
      As you can see it has created the perl5/ folder I mention.

      Could you please suggest the correct way to install modules in this perl lib such that the module files sit in the given lib/5.32.0 or lib/site_perl area?

      Thank you again!

        You should be able to just run:

        cpanm Module

        Don't use -L . — it already knows the right place to install it.

        "Such that I can have my scripts work seamlessly by just pointing the shebang to the perl bin. E.g. $PERLBREW_ROOT/perls/perl-5.32.0/bin/perl in this case."

        I start all of my scripts with the following shebang. This includes those I write for myself, scripts I post here, and those I write for work in a production environment.

        #!/usr/bin/env perl

        That may work for you also. See perlrun for more details about this.

        — Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found