perlperlbrew

How to clone a Perlbrew install


I use Perlbrew to manage local Perl binary installs. I'd like to clone the current install so that I can test out a new CPAN module, and then revert if I don't like the module. I'd rather not wait the 20+ minutes it would to to create a new Perlbrew install and replicate the current module downloads I already have.

The only thing I can think of to do is to use Git to manage the Perlbrew install, making sure the repo is clean before I do my test, and use Git to revert the Perlbrew install if I don't want to keep the new CPAN module (or commit the changes if I do like it). Is there a better way to do it?


Solution

  • If by cloning, you mean to replicate a given installation to a different location, there are multiple factors that makes this seemingly trivial problem less than trivial:

    1. whether the installations of perl are relocatable (perl -V:config_args | grep -o 'userelocatableinc' ) -- if not, the replicas has to be be placed on somewhere with identical path.
    2. whether perl itself refers to some function from some external dynamic libraries (`nm $(which perl) | grep ' U ')
    3. whether the modules contained in installation refers to some external dynamic libraries (IO::Socket::SSL might be the most well-known case)

    If the purpose is for single-user on just one computer system, that means all those 3 factors are non-issues, then the easiest way is to just maintain a file-system level copy with whatever tool you prefer (cp -R would suffice) to make copies of both $PERLBREW_ROOT.

    Issue 1 can be easily dealt with by adding -Duserelocatableinc when doing perlbrew install

    Issue 2 and 3 requires preparation on the OS. Identical libraries just needs to be installed in all places.

    If you also use the lib feature to manage multiple repos of libs, you'll have to keep copies of content under $PERLBREM_HOME.