mfort has asked for the wisdom of the Perl Monks concerning the following question:

I've done research on relocating an already installed perl and found an article from the DWIMPerl author, but it seemed to trail off.

I've built a standard/stock perl-5.24.1 for Windows 64-bit on Win 2012R2 using Visual Studio 10. Once I installed it to a directory, I made a tarball of the directory. Later, upon extracting that tarball to a different directory, the relocatability seems to work fine finding modules in the new library location. However, I am trying to CPAN install other modules and getting errors with make trying to reference paths from the original install location.

  1. Since Windows builds do not use the Configure script, I have made changes to the win32/Makefile. Does this file support the '...' functionality that Configure does for unix, i.e. allowing paths to be relative to Perl (perl.exe)?
  2. Once the installed perl is moved to another directory, was the original intention of the author(s) to allow CPAN modules to be installed on that perl?
  3. I read a lot online about reloc_perl, relocate_perl type scripts (CitrusPerl, DWIMPerl, etc). Is there a standard process that can be followed to know that I've patched all the right files (Config.pm, Config_heavy.pl, and other binary/text files within the install directory)?

Replies are listed 'Best First'.
Re: Relocatable Perl
by Corion (Patriarch) on Apr 14, 2017 at 21:38 UTC

    Windows Perl has always been relocatable, in the sense that you can move perl.exe and its accompagnying files into any directory you like.

    The configuration used by Perl and CPAN is a second matter, and they are mostly patched by some script in the distribution. The two main files to look at are Config.pm (and thus, Config_heavy.pl) and CPAN/Config.pm , as these contain absolute paths.

      > Windows Perl has always been relocatable, in the sense that you can move perl.exe and its accompagnying files into any directory you like

      At least regarding ActiveState Perl this is not 100% correct.

      There are various hard coded paths in the distribution making maintenence after the move kind of complicated.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

      When you say 'they are mostly patched by some script in the distribution', what script in the core perl distribution are your referring to?

      I looked for anything in the bin directory that looked like it would relocate the installation, but found nothing. Remember, I am using the raw perl source and building myself.

        Weird - I was certain that Perl now included its own script to patch the absolute paths in the relevant files, but it seems no such thing is in the Perl core.

        You could look at what Portable::Dist does to patch a Perl distribution, or what ActiveState does and replicate that.

Re: Relocatable Perl
by dasgar (Priest) on Apr 14, 2017 at 22:40 UTC

    Perhaps you could take a look at how Strawberry Perl handles this for their portable editions.

    Also, stevieb has put a considerable amount of work into berrybrew (originally created by David Farrell - see his blog post about it), which is an attempt to be something like perlbrew for Windows by using the Strawberry Perl's portable editions. Depending on what your needs are, you might find berrybrew helpful to use.

      Nothing with "brew" in the name has anything to do with relocatability
Re: Relocatable Perl
by FreeBeerReekingMonk (Deacon) on Apr 15, 2017 at 10:06 UTC
    xammp has served me well in the past. It contains a portable perl directory. Maybe it is useful. It contains perlIVP, perlivp - Perl Installation Verification Procedure It will at least verify some basic things.

    So maybe perlivp fails if you relocate perl into another directory (make sure you use a clean Windows without perl)

    Maybe you could meld/windiff xampp's perl directory with yours...

Re: Relocatable Perl (use Portable;)
by Anonymous Monk on Apr 14, 2017 at 22:09 UTC
      use Portable;

      I doubt that this will be of much use to the OP.

      Cheers,
      Rob
        :) Why? UTSL you'll find out different

      I looked at Portable, just like Gábor mentioned here in 2014, http://www.perlmonks.org/?node_id=1102042 and came to the same conclusion.

      Portable seems like it will help with scripts and perl changing drive letters and stuff like that. Although I might eventually have that problem, the key issue/question is how can someone install a CPAN module on a relocated perl.

        Heh try it it works

        itd be a pointless module otherwise and all this stuff would do nothing

        Modules Portable - Perl on a Stick Provides CPAN::Mini::Portable in lib/CPAN/Mini/Portable.pm Portable::Config in lib/Portable/Config.pm Portable::CPAN in lib/Portable/CPAN.pm Portable::FileSpec in lib/Portable/FileSpec.pm Portable::HomeDir in lib/Portable/HomeDir.pm Portable::LoadYaml in lib/Portable/LoadYaml.pm Portable::minicpan in lib/Portable/minicpan.pm
        But then Agaain Re^3: How to create relocatable perl 5.20.1 ? ( reloc_perl)