Re: *more* relocatable perl

[email protected] (Leon Timmermans) Sat, 18 Jul 2026 22:24:38 +0200
Newsgroups perl.perl5.porters
Message-ID <CAHhgV8hRs2Nn5MsgkHPvn+7cHGNxYmJ+YrejMWJZCSXLOjsdHA@mail.gmail.com>
--0000000000000849550656e87799
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',
>
> `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?)


I suspect you can make this work by using the usesitecustomize feature to
monkeypatch various %Config values. %Config can be monkeypatched by
(ab)using its tied value.

Leon

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

<div dir=3D"ltr"><div dir=3D"ltr"></div>On Thu, Jul 16, 2026 at 2:09=E2=80=
=AFPM Gianni Ceccarelli via perl5-porters &lt;<a href=3D"mailto:perl5-porte=
[email protected]">[email protected]</a>&gt; wrote:<div class=3D"gmail_quote=
 gmail_quote_container"><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">H=
ello!<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;,<br>
<br>
`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>I suspect y=
ou can make this work by using the usesitecustomize feature to monkeypatch =
various %Config values. %Config can be monkeypatched by (ab)using its tied =
value.</div><div><br></div><div>Leon</div></div></div>

--0000000000000849550656e87799--