App-perlbrew icon indicating copy to clipboard operation
App-perlbrew copied to clipboard

We should switch `perlbrew` to use `/usr/bin/env perl`

Open KES777 opened this issue 7 years ago • 4 comments

I am on Red Hat 4.4.7-17

$ cat /proc/version
Linux version 2.6.32-642.13.1.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) ) #1 SMP Wed Jan 11 20:56:24 UTC 2017

After installing and switching to perlbrew's perl the perlbrew command continues refer to system perl

$ head -n 1 perl5/perlbrew/bin/perlbrew 
#!/usr/bin/perl

This cause error:

$ perlbrew
Can't locate parent.pm in @INC (@INC contains: FatPacked::39209768=HASH(0x2564b28) /home/mmkeeper/monkeyman/lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /home/mmkeeper/perl5/perlbrew/bin/perlbrew line 34928.

The cpanm does not bother:

$ head -n 1 perl5/perlbrew/bin/cpanm 
#!/usr/bin/env perl

Should we switch perlbrew and patchperl scripts to use /usr/bin/env perl instead of /usr/bin/perl?

KES777 avatar Jun 14 '18 09:06 KES777

No. These shebangs are rewritten when installing App::perlbrew. /usr/bin/env perl is not, so it would execute with the wrong perl.

The fatpacked script which is not installed via CPAN could use /usr/bin/env perl however, I think this is not done because perlbrew itself would then run via the perls it installs when it alters the environment, and this leads to insanity.

Grinnz avatar Jun 16 '18 00:06 Grinnz

RHEL4 is very old, I'm not sure how supported this use case is. You may be able to get it working by installing the necessary modules in your system perl via yum.

Grinnz avatar Jun 16 '18 00:06 Grinnz

Thanks @KES777 , but previously, using env perl to run perlbrew itself created some some known issues, mostly when loading core, XS-based modules, namely Cwd. Thought I havn't re-visit this matter for a few years, perhaps my memory needs to be refreshed. (I'm relatively sure that this has been recorded in github issues and git commits.... :)

This problem of missing dependencies needs to be resolved from: https://github.com/gugod/App-perlbrew/blob/develop/dev-bin/build.sh

I have no way of knowing whether parent.pm is the only missing depenedncy or not though.

OTHO, the cpanm installed by perlbrew install-cpanm must be invoed with env perl (shebang #!/usr/bin/env perl), otherwise it cannot work with perlbrew swich or perlbrew use.

gugod avatar Jul 24 '18 02:07 gugod

DragonFly BSD doesn't have /usr/bin/perl which causes the following error during perlbrew self-upgrade:

[17:50] xenu@carychium-tridentatum:~% perlbrew self-upgrade
Can't exec "/tmp/perlbrew": No such file or directory at /home/xenu/perl5/perlbrew/bin/perlbrew line 2127.
Use of uninitialized value $new_version in scalar chomp at /home/xenu/perl5/perlbrew/bin/perlbrew line 2128.
Use of uninitialized value $new_version in pattern match (m//) at /home/xenu/perl5/perlbrew/bin/perlbrew line 2129.
Unable to detect version of new perlbrew!

symlinking /usr/bin/perl to /usr/local/bin/perl makes it work.

xenu avatar Nov 01 '18 16:11 xenu