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

"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.

  • Comment on Re^2: Why is lib/perl5 not added to INC for perls installed using perlbrew

Replies are listed 'Best First'.
Re^3: Why is lib/perl5 not added to INC for perls installed using perlbrew
by areldy_exten (Novice) on Sep 12, 2020 at 13:09 UTC
    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.

        That worked!
        Thank you.
      "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

        Yep, this is what I do too, and it means that the script will just run under whatever version of Perl I've most recently selected in Perlbrew. That's usually what I want.

        I start all of my scripts with the following shebang. [...]

        #!/usr/bin/env perl

        Digging into the details, this starts the env program, which then searches for the first perl executable in $ENV{PATH}. So this increases the startup time slightly. Also, env is not always in /usr/bin. Some Linux distributions put it into /bin and add a symlink in /usr/bin. Some other Unixes have env only in /bin, with no symlink in /usr/bin. In that case, all of your scripts will simply fail. See also far more you ever wanted to know about #!.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)