2

I have a remote CentOS server (Release 6.10) set up by someone else. I have quite a few perl modules installed on the machine.

I have set up a local CentOS server (Release 7.7.1908). I would like to have the EXACT same set of perl modules on my local machine. Installing them one by one via cpan is an option but I can run into issues as some of the perl modules are older (very) versions.

I was wondering, if I can copy modules from the remote server to my local server. Can I do that? Are there other options?

user2125853
  • 1,265
  • 4
  • 13
  • 23
  • You can cross mount directory with modules to your server and add it into `@INC` variable with `PERLLIB` and/or `PERL5LIB` variables. [How to change @INC to find Perl modules in non-standard locations](https://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations). In this way you have to support only one modules repository (less work). Your network connection should be reliable enough or otherwise disconnect will be unpleasant surprise. – Polar Bear May 14 '20 at 18:45
  • If you copy modules to server as a reminder make `backup copy` in case if you have `to retreat on previous position`. If _remote server_ is truly remote and NFS,SSH mount is not possible then copy is only option. In this case you have to find _very old modules_ copy them to your local server and install through cpan only latest modules you consider safe. – Polar Bear May 14 '20 at 18:51
  • Other possible approach is use virtual environment like [Docker](https://www.docker.com/). Create VM and try recreate perl environment from remote server. In this way you will have two separate isolated perl environments on same machine. – Polar Bear May 14 '20 at 18:55
  • 1
    Please see if the following [instruction](https://stackoverflow.com/questions/47573728/how-do-i-re-install-a-cpan-autobundle) of any help. – Polar Bear May 14 '20 at 19:04

2 Answers2

4

It's not safe to copy modules from one machine to another because things may not be set up identically. It's best to reinstall them.

You can use the autobundle command in the cpan shell to create a dump of all the modules you have installed on the old machine. You can then use that dump to tell the cpan shell on the new machine what modules to install.

Thanks to Polar Bear, here's a link to an article that explains how to reinstall the autobundle.

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
0

The solution suggested by Andy Lester is perhaps the best way to do it. I found a documentation here in addition to ones suggested.

In my case however this was not straight forward because the source server environment is very old and there were many dependencies that I will need to manually resolve. In general if you have similar environments and clean installs, the auto bundle approach will make it easy.

user2125853
  • 1,265
  • 4
  • 13
  • 23