Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Replicate Perl setup

by nikosv (Deacon)
on Dec 10, 2021 at 13:04 UTC ( [id://11139542]=perlquestion: print w/replies, xml ) Need Help??

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

Is there a way to "clone" a Perl setup/environment from one machine to another identical one ?
With that I mean, to copy the modules of the specific version they are in from the old machine to the new machine.
I want that because I'm afraid to install the newest modules on the new machine in case there are incompatibilities. thanks

Replies are listed 'Best First'.
Re: Replicate Perl setup
by Fletch (Bishop) on Dec 10, 2021 at 13:37 UTC

    The CPAN module has an autobundle command which will write a Bundle::Snapshot_YYYY_MM_DD_XX (the last XX being a counter) containing a list of modules and revisions which are installed that you can use to have it reinstall the same set. You could use that to prime an install of the same base perl version somewhere else which (depending on the OS and compiler state) should be more or less identical.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      this looks promising, thanks!
      Does this work even with modules install with cpanm (cpan minus) ?

        It uses the list/manifest of installed modules which is written by the module’s make install process which is independent of what you use to install. So long as you’re not (say) copying things into the lib hierarchy by hand it’ll find things.

        Edit: Afterthought if you’re asking can cpanm install a bundle module list generated by CPAN . . . That’s actually an interesting question and I’m not sure. The bundle pod is written into the .cpan config dirs and I don’t know if minus can/would look there; but if it (App::cpanminus) can handle them I’d bet it would. Personally when using this feature I’m bootstrapping a new Perl install and I’m expecting minus to be one of the things to get installed by said bundle so it’s not anything I’ve tried.

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

Re: Replicate Perl setup (Building and Installing Perl References)
by eyepopslikeamosquito (Archbishop) on Dec 11, 2021 at 00:43 UTC
Re: Replicate Perl setup
by LanX (Saint) on Dec 10, 2021 at 13:22 UTC
    > to copy the modules of the specific version they are in from the old machine to the new machine

    That depends on hardware and OS.

    On windows copying the directory tree is sufficient, at least with ActiveState.

    I think I heard you can do similar things on Linux if the OS and hardware are sufficiently close, but you'll have to replicate some ENV-settings too.

    It mainly boils down to the binary compatibility of installed XS modules, otherwise they need to be recompiled.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      On windows copying the directory tree is sufficient, at least with ActiveState.

      This is true, but AS licensing agreements from years ago prohibited that for actual product shipment. I don't know what current AS licensing says for a re-distributed product. I suspect potential legal trouble if this is done for end-product distribution vs perhaps in-house use.

      At the time, I bought a Perl Dev Kit license and generated an .exe file for just that legal reason. Of course the Dev Kit has been discontinued.

      AS did have some tools for "cloning" an installation. You ran a utility to make an XML file. You installed Perl directly from AS (no binary distribution allowed) on the target machine. Then there was a utility that used this XML file which was supposed to re-create the environment on the target machine. I had trouble with that and I think many others did too.

      The new AS way is to create an account on their site and have AS build a version for you with the modules that you need. The result of this is an installable MSI file or equivalent in the Unix world. That AS built version (which includes XS binaries for your platform) can be freely re-distributed without restriction. In the Windows world, this is good. There of course can be complex issues with multiple Perl versions on any platform.

      thanks
Re: Replicate Perl setup
by davido (Cardinal) on Dec 10, 2021 at 16:25 UTC

    This may also be solved using containers. Docker + Carton (for dependencies) + make, for example.


    Dave

      This is how the cool kids do it.
Re: Replicate Perl setup
by karlgoethebier (Abbot) on Dec 11, 2021 at 18:13 UTC

    Couldn’t you clone the machine(s)? In the last company i was with we had some success with this procedure. Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re: Replicate Perl setup
by perlfan (Vicar) on Dec 12, 2021 at 23:01 UTC
    > I'm afraid to install the newest modules on the new machine in case there are incompatibilities

    Don't be a 'frady cat. No matter what you use an environment - docker, perlbrew, virtualbox, etc - see how far you can get with just a test environment; installing the packages from CPAN or, better, the local package manager. Fix your code where you need to. Once you get that working, your life will be a lot simpler and you'll see how silly being "afraid" actually is. I'd rather be seeing you post questions here regarding the fixing of your code than to enable you to just live in some false sense of fear.

      One caveat from experience (and if you search through my post history I'm probably a broken record about this):

      Never use the OS' perl and package manager if you don't have 100% control over the OS. With today's container solutions that's less of an issue (since you're more likely to have full control over the image inside), but if you're still on bare metal and at the whim of (say) a central IT department you're going to get bitten at some point. They're going to upgrade your perl and/or packages underneath your application without your knowledge or consent at some point (Murphy sez) and then you're going to be the unfortunate schmuck on the hook to unbreak what they've just broked (because you didn't plan on Foo::Bar suddenly throwing an error because there was an upstream bug your existing code exercised but wasn't handling that's now fixed).

      Always roll and maintain your own application install somewhere you control and use that instead of /usr/bin/perl or whatever. Make sure to shebang everything #!/usr/bin/env perl rather than an explicit path then manage PATH to find what to run (that also allows you to test and migrate to a new version without editing all your scripts).

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-25 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found