gugod / App-perlbrew

Manage perl installations in your $HOME
https://perlbrew.pl
Other
716 stars 215 forks source link

cpan: install a module, then perl search @INC system wide #773

Closed sputnick-dev closed 1 year ago

sputnick-dev commented 1 year ago

(all is up2date)

$ cpan Text::Format
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/home/me/.cpan/Metadata'
  Database was generated on Fri, 10 Mar 2023 23:54:10 GMT
CPAN: Module::CoreList loaded ok (v5.20220520)
Text::Format is up to date (0.62).

Then if I run a script that depends on this module I get:

Can't locate Text/Format.pm in @INC (you may need to install the Text::Format module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.34.0 /usr/local/share/perl/5.34.0 /usr/lib/x86_64-linux-gnu/perl5/5.34 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.34 /usr/share/perl/5.34 /usr/local/lib/site_perl) at /path/to/script line 34.
BEGIN failed--compilation aborted at /path/to/script line 34

As a workaround, I can run successfully my script if I run before:

PERL5LIB=/home/me/perl5/perlbrew/perls/perl-5.36.0/lib/site_perl/5.36.0

perlbrew info

$ perlbrew info
Current perl:
  Name: perl-5.36.0
  Path: /home/me/perl5/perlbrew/perls/perl-5.36.0/bin/perl
  Config: -de -Dprefix=/home/me/perl5/perlbrew/perls/perl-5.36.0 -Aeval:scriptdir=/home/stardust/perl5/perlbrew/perls/perl-5.36.0/bin
  Compiled at: Jan  2 2023 18:11:37

perlbrew:
  version: 0.96
  ENV:
    PERLBREW_ROOT: /home/me/perl5/perlbrew
    PERLBREW_HOME: /home/me/.perlbrew
    PERLBREW_PATH: /home/me/perl5/perlbrew/bin:/home/me/perl5/perlbrew/perls/perl-5.36.0/bin
    PERLBREW_MANPATH: /home/me/perl5/perlbrew/perls/perl-5.36.0/man

Any clue?

gugod commented 1 year ago

Then if I run a script that depends on this module I get:

Is the shbang (the very first line) of the script #!/usr/bin/perl ? If that's the case that script would always be ran by /usr/bin/perl instead of whatever perl managed by perlbrew.

You could try changing the shbang to be #!/usr/bin/env perl -- this makes it ran by env that env picks up whatever perl in $PATH and hopefully that'd be the right one managed by perlbrew.

sputnick-dev commented 1 year ago

Hey, makes sense!

Thanks