git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] global: resolve Perl executable via PATH

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 5, 2023, 17:09 UTC
Message-ID
<CAMP44s1V3nGnqCjoCi2xuH59APVPiAoQ82LQx3KNnsdDNfcoPg@mail.gmail.com>
In-Reply-To
<ZC2ZyTTZFbd_gNtw@pobox.com>
On Wed, Apr 5, 2023 at 11:31 AM Todd Zullinger <tmz@pobox.com> wrote:
Show 16 quoted lines
>
> Patrick Steinhardt wrote:
> > On Wed, Apr 05, 2023 at 10:42:52AM -0400, Todd Zullinger wrote:
> >> Is there a reason to not set PERL_PATH, which is the
> >> documented method to handle this?  From the Makefike:
> >>
> >> # Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl).
> >
> > Setting PERL_PATH helps with a subset of invocations where the Makefile
> > either executes Perl directly or where it writes the shebang itself. But
> > the majority of scripts I'm touching have `#!/usr/bin/perl` as shebang,
> > and that path is not adjusted by setting PERL_PATH.
>
> Ahh.  I wonder if that's intentional?  I haven't dug into
> the history, so I'm not sure.  It seems like an oversight,
> as an initial reaction.

Generally the people interested in setting PERL_PATH are packagers, and it's so the installed scripts have the desired hardcoded path.

So a script that is never installed isn't considered.
Show 8 quoted lines
> > I'd be happy to amend the patch series to only fix up shebangs which
> > would not be helped by setting PERL_PATH. But if we can make it work
> > without having to set PERL_PATH at all I don't quite see the point.
>
> It's certainly debatable whether using /path/to/env perl is
> better than hard-coding it at build time (forgetting about
> the usage of RUNTIME_PREFIX). [Debatable in a friendly
> sense, of course.]

It's better because it allows the user to choose another version dynamically, for example:

    PATH=/opt/perl7/bin:$PATH script
> As a distribution packager, I prefer to set the path at
> build time to help ensure that an end user can't easily
> break things by installing a different perl in PATH.
And as a user I would rather packagers don't treat me like a child.
I decide how to use *my* system.

And BTW, newer generations of developers use all kinds of version managers like RVM and nvm, and perl has one as well: perlbrew [1]. Not to mention docker, for which the Perl official image installs into /usr/local/bin/perl.

> The Fedora build system will munge /path/to/env perl
> shebangs to /usr/bin/perl and it won't effect us much.

So you can override '#!/usr/bin/env perl' instead of overriding `#!/usr/bin/perl`, which the Git Makefile does by default anyway.

What's the difference to you?
> That may not be true for other distributions and they may
> care more if they want to keep using a hard-coded path to
> perl.
Arch Linux does whatever upstream does by default.
> I don't know how it may affects the Windows folks either, who are
> further askew from our other, more UNIX-like targets.
Windows doesn't use shebangs, you have to do `perl script`.
> I don't know what the right choice is for upstream Git, it
> can easily be argued in either direction. :)

I don't think it matters to packagers how people developing Git run the internal scripts.

Cheers.
[1] https://metacpan.org/pod/perlbrew
-- 
Felipe Contreras
Previous: Todd ZullingerNext: Patrick Steinhardt
Message 7 of 27 in “global: resolve Perl executable via PATH”
  1. global: resolve Perl executable via PATHPatrick Steinhardt, Apr 5, 2023
  2. Felipe ContrerasApr 5, 2023
  3. Patrick SteinhardtApr 5, 2023
  4. Todd ZullingerApr 5, 2023
  5. Patrick SteinhardtApr 5, 2023
  6. Todd ZullingerApr 5, 2023
  7. Felipe ContrerasApr 5, 2023
  8. Patrick SteinhardtApr 5, 2023
  9. Junio C HamanoApr 5, 2023
  10. Felipe ContrerasApr 6, 2023
  11. Jeff KingApr 5, 2023
  12. Patrick SteinhardtApr 5, 2023
  13. Jeff KingApr 5, 2023
  14. Felipe ContrerasApr 6, 2023
  15. Jeff KingApr 6, 2023
  16. Ævar Arnfjörð BjarmasonApr 6, 2023
  17. Felipe ContrerasApr 18, 2023
  18. Patrick SteinhardtApr 6, 2023
  19. Kristoffer HaugsbakkApr 5, 2023
  20. Eric WongApr 5, 2023
  21. Felipe ContrerasApr 6, 2023
  22. Ævar Arnfjörð BjarmasonApr 6, 2023
  23. Jeff KingApr 6, 2023
  24. Patrick SteinhardtApr 6, 2023
  25. t/lib-httpd: pass PERL_PATH to CGI scriptsJeff King, Apr 6, 2023
  26. Junio C HamanoApr 6, 2023
  27. Felipe ContrerasApr 18, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.