Re: *more* relocatable perl

Leon Timmermans <[email protected]> Tue, 21 Jul 2026 14:08:56 +0200
Newsgroups gmane.comp.lang.perl.perl5.porters
Message-ID <CAHhgV8jzPReRm5LiVUXfSx+4EuuHqE=oLAwaxxZx=EM=i2JxYA@mail.gmail.com>
--000000000000d34a7e06571de378
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Jul 16, 2026 at 2:09=E2=80=AFPM Gianni Ceccarelli via perl5-porters=
 <
[email protected]> wrote:

> Hello!
>
> For $work, I need to build a `perl` that can be copied in different
> locations, and should work fine from any of them.
>
> Of course I started with `-Duserelocatableinc`, which takes care of
> `@INC` and a few `%Config` entries (prefixexp archlibexp privlibexp
> sitearchexp sitebinexp sitelibexp sitescriptexp siteprefixexp
> sitelib_stem installarchlib installprefixexp installprivlib
> installsitearch installsitebin installsitelib installsitescript)
>
> But it does not take care of installbin installprefix
> installscript perlpath scriptdir scriptdirexp startperl
>
> startperl and perlpath are used by CPAN modules
> (e.g. `ExtUtils::Helpers::make_executable`,
> `ExtUtils::MM_Unix::fixin`) to (re)write the shebang line of programs,
> and a few other libraries use those in their tests.  Therefore, moving
> a "relocatable INC" perl to a different directory and trying to
> install some modules, often fails.
>
> I have worked around the issue in my builds, by patching `Config.pm`
> to apply a simplified version of `relocate_inc` to those other
> settings, and I think it's good enough _for me_.
>
> But=E2=80=A6
>
> Would it be sensible to have a `-Duserelocatablebin` that has the same
> effect as `userelocatableinc`, but for the other settings?
>
> So for example you'd get, in `Config.pm`:
>
>     scriptdir =3D> '.../',
>
> instead of
>
>     scriptdir =3D> '/home/dakkar/perl5/perlbrew/perls/perl-5.44.0/bin',


The problem with such an approach is that shebang lines don't change when
you relocate your perl, so all scripts will suddenly break.

We don't really have a good solution for that, though I can think of some
terrible solutions (involving a little bit of shell at the top of every
perl script that finds the right perl and executes that).


> `bin` and `binexp` are already set to `.../` when `userelocatableinc`
> is set (although, weirdly, they don't get filtered through
> `relocate_inc()`=E2=80=A6 bug?)


Yeah that sounds like a bug. But I don't think anything uses either after
install so I'm not surprised no one ran into that before.

--000000000000d34a7e06571de378
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">On Thu,=
 Jul 16, 2026 at 2:09=E2=80=AFPM Gianni Ceccarelli via perl5-porters &lt;<a=
 href=3D"mailto:[email protected]" target=3D"_blank">perl5-porters@per=
l.org</a>&gt; wrote:</div><div class=3D"gmail_quote"><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204=
,204,204);padding-left:1ex">Hello!<br>
<br>
For $work, I need to build a `perl` that can be copied in different<br>
locations, and should work fine from any of them.<br>
<br>
Of course I started with `-Duserelocatableinc`, which takes care of<br>
`@INC` and a few `%Config` entries (prefixexp archlibexp privlibexp<br>
sitearchexp sitebinexp sitelibexp sitescriptexp siteprefixexp<br>
sitelib_stem installarchlib installprefixexp installprivlib<br>
installsitearch installsitebin installsitelib installsitescript)<br>
<br>
But it does not take care of installbin installprefix<br>
installscript perlpath scriptdir scriptdirexp startperl<br>
<br>
startperl and perlpath are used by CPAN modules<br>
(e.g. `ExtUtils::Helpers::make_executable`,<br>
`ExtUtils::MM_Unix::fixin`) to (re)write the shebang line of programs,<br>
and a few other libraries use those in their tests.=C2=A0 Therefore, moving=
<br>
a &quot;relocatable INC&quot; perl to a different directory and trying to<b=
r>
install some modules, often fails.<br>
<br>
I have worked around the issue in my builds, by patching `Config.pm`<br>
to apply a simplified version of `relocate_inc` to those other<br>
settings, and I think it&#39;s good enough _for me_.<br>
<br>
But=E2=80=A6<br>
<br>
Would it be sensible to have a `-Duserelocatablebin` that has the same<br>
effect as `userelocatableinc`, but for the other settings?<br>
<br>
So for example you&#39;d get, in `Config.pm`:<br>
<br>
=C2=A0 =C2=A0 scriptdir =3D&gt; &#39;.../&#39;,<br>
<br>
instead of<br>
<br>
=C2=A0 =C2=A0 scriptdir =3D&gt; &#39;/home/dakkar/perl5/perlbrew/perls/perl=
-5.44.0/bin&#39;,</blockquote><div><br></div><div>The problem with such an =
approach is that shebang lines don&#39;t change when you relocate your perl=
, so all scripts will suddenly break.</div><div><br></div><div>We don&#39;t=
 really have a good solution for that, though I can think of some terrible =
solutions (involving a little bit of shell at the top of every perl script =
that finds the right perl and executes that).</div><div>=C2=A0</div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">
`bin` and `binexp` are already set to `.../` when `userelocatableinc`<br>
is set (although, weirdly, they don&#39;t get filtered through<br>
`relocate_inc()`=E2=80=A6 bug?)</blockquote><div><br></div><div>Yeah that s=
ounds like a bug. But I don&#39;t think anything uses either after install =
so I&#39;m not surprised no one ran into that before.</div></div></div>
</div>
</div>

--000000000000d34a7e06571de378--