Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: @INC not reflecting correctly

by syphilis (Archbishop)
on Aug 27, 2021 at 09:30 UTC ( [id://11136119]=note: print w/replies, xml ) Need Help??


in reply to Re^3: @INC not reflecting correctly
in thread @INC not reflecting correctly

I'm pretty sure this is something that the Strawberry Perl Portable editions work around

As regards @INC on Windows, there's no need to work around anything as wrt the setting of @INC.
For example, I have a build of perl-5.30.0 in the location C:/_64/perl530_810.
It reports @INC as being:
C:/_64/perl530_810/site/lib C:/_64/perl530_810/lib
I copy that perl to a new location of C:/_64/C/perl530_810.
Without any need for me to take any additional action at all, this new perl installation correctly reports @INC as being:
C:/_64/C/perl530_810/site/lib C:/_64/C/perl530_810/lib
This is something that happens automatically on Windows. (I think it just looks at the location of the perl executable and derives @INC accordingly.)
However, Linux (amazingly) apparently does not provide such a convenience.

It's not quite so simple for portable Strawberry Perl wrt the correct treatment of %Config settings.
I think they're probably just rewriting Config.pm and Config_heavy.pl at time of installation.
(Again, this is a convenience that is unavailable to Linux.)

Cheers,
Rob

Replies are listed 'Best First'.
Re^5: @INC not reflecting correctly
by swl (Parson) on Aug 27, 2021 at 23:55 UTC

    Fair point WRT @INC. I still wonder about Config, though.

    The portable version of Strawberry Perl is not installed per se. It just lives in a folder and can be moved around without needing any additional steps to tell Perl where it has been moved to. There are some runtime effects on Config based on the location of the binary, and those are what I cannot locate the source of. Whether those have any bearing on @INC is another question, of course.

    Edit: I think this is answered by haj in 11136120, and is the Portable module.

      I still wonder about Config, though.

      It's quite easy to change %Config values - and the same method works on all systems.
      Just create a file named (say) New_Config.pm:
      package New_Config; use Config; my $new = tied %Config; $new->{make} = 'dmake'; $new->{byteorder} = '43215678'; # Specify as many as you like 1;
      Then you'll see:
      C:\>perl -V:byteorder byteorder='12345678'; C:\>perl -MNew_Config -V:byteorder byteorder='43215678'; C:\>perl -V:make make='gmake'; C:\>perl -MNew_Config -V:make make='dmake';
      The first I became aware of this was with Mattia Barbon's EU::FakeConfig.
      This was very useful as it allowed the use of gcc toolchains to build and install XS modules on perl's built using an MSVC toolchain. (This was back in the day when ActiveState were providing perl's built using MSVC-6.0.)

      I haven't checked to see whether this technique is utilised by Strawberry Perl in achieving its relocatability.
      IIRC, on Windows some Config keys can be altered by editing Config.pm and Config_heavy.pl - but there are also keys that, to my knowledge, can only be changed via this "tied hash" approach.

      Cheers,
      Rob
        It's quite easy to change %Config values - and the same method works on all systems. Just create a file named (say) New_Config.pm:
        You should be aware that changing paths in Config.pm has no effect on @INC. The point of the hack in ExtUtils::FakeConfig is to fool other programs about how this Perl has been built. Other programs use Config and act accordingly. For Perl itself it is just a report written at build time, the Perl executable does not read it (unless you start with perl -d as the debugger does use it).
Re^5: @INC not reflecting correctly
by bliako (Monsignor) on Aug 28, 2021 at 04:58 UTC
    However, Linux (amazingly) apparently does not provide such a convenience. 

    It's not that amazing: in Linux the dir(s) containing the executable(s) is common to all installed programs: /bin, /sbin, /usr/bin, /usr/local/bin. It is not the case that each program has its own private bin/, lib/ (include/, etc/) and keep adding private bin/ dirs to the PATH, which (the PATH) being such a primitive structure it is "difficult" to add a path somewhere in the middle, say, in order to precede some similarly-named program, e.g. another Perl. With a common bin/ dir (Linux), programs have to either overwrite existing one or be renamed. Deriving the INC by and relative to the location of the executable can not work in Linux (5' EDIT: see Re^5: Devel::NYTProf: "undefined symbol: PL_stack_sp" error for how paths are hardcoded within libraries). Or any other sane OS which likes to put its soldiers to a communal camp, provided they all keep clean socks. In this way, a single bin/ file-permissions and other security policy will be saner to maintain. Additionally, there are (usually) no private program installations (re: "Do you wish to install this program for all users or just for you?") except in a groups-based way (e.g. admin, staff, etc.). Again, easier to maintain security policy. The results are obvious from a glance at the battlefield: virtually each and every windows box is pawned (including that windows XP of UK's 3bn nuclear air-carrier, see also here, for the other side of the story).

    bw, bliako

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11136119]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found