Peculiar perl version issue

Bruce R Miller bruce.miller at
Wed Jun 12 18:41:40 UTC 2019

On 6/12/19 1:14 PM, Ryan Schmidt wrote:
> On Jun 12, 2019, at 10:26, Bruce Miller wrote:
>> So, apparently the perl portgroup replaces shebang
>> lines that it recognizes with a call to the specific
>> perl that was specified in the portfile (? is that right?)
>> And if so, it doesn't recognize the above line,
>> so it leaves it alone.
> I can't find any code in the perl5 portgroup that replaces shebang lines. But if you need to do that, it's easy to write an fs-traverse/reinplace loop to do so. Many other ports do something like that, so you can probably find a few lines of code in another portfile that you can copy and paste.

Seems like it would have to do something like that.
The normal approach for an executable perl script
would be
   #!/usr/bin/perl -w
and that would fail under macports for exactly the
same reasons as env perl does.

But, given your clue, I poked around and found this in
cpan2port's Portfile:
configure {
     reinplace "s|#! /usr/bin/env perl|#!${prefix}/bin/perl${perl5.major}|g" ${worksrcpath}/${name}

I'm not much of a tcl programmer, but it looks close to what
I'm looking for... just need to loop over the executables...

>> Since LaTeXML specifies perl 5.26 (Yes, I know
>> I need to update it, but that's only a shortterm fix),
>> and macports is installing both 5.26 and 5.28,
>> all of LaTeXML's modules go under
>>   /opt/local/lib/perl5/vendor_perl/5.26
>> and env perl -v shows
>>   This is perl 5, version 28...
> FYI, env perl -v shows version 5.28 because you have installed the perl5 port with the +perl5_28 variant. But a user might install it with a different variant and then env perl -v would be a different version for them. Point being: you can't rely on "perl" being a particular version on a user's system.

Yep, exactly.  As long as LaTeXML's modules are installed version specific,
and if there's multiple perls, it's a crapshoot whether env perl gives you
the "right" one.

BTW, I didn't explicitly install *any* perl; This was a fresh install on
a new mac: basically install XCode, cmdline tools, macports, selfupgrade
and then port install LaTeXML (+MacTeX).  So I got 5.26 because of LaTeXML,
and 5.28 apparently for free.

Thanks for the clues!

bruce.miller at

More information about the macports-dev mailing list