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

How do I locally host a CPAN repository on an air-gapped server, and populate the repository with some popular Perl packages ?

Is there a way to:

  1. Export the current state of a Perl virtual environment to a file (eg. interpreter version, all modules etc)
  2. Transfer the export file to a laptop where cpan shell can access the internet
  3. Run cpan against the export file (as a baseline reference) to download required packages
  4. Import the downloaded packages to the locally hosted CPAN repository
  • Comment on How do I locally host a CPAN repository on an air-gapped server ?

Replies are listed 'Best First'.
Re: How do I locally host a CPAN repository on an air-gapped server
by marto (Cardinal) on Aug 13, 2024 at 06:30 UTC

    You may want to consider minicpan (provided buy CPAN::Mini) to create and maintain an 'offline' cpan mirror. I do this for work, use the tool to create a mirror on a machine with internet access, transfer it to our offline network, point cpan/cpanm towards the files.

    To export all modules etc just run cpan -a to create an 'autobundle'.pm package, which you can copy elsewhere and apply via perl -MCPAN -e 'install Bundle::Snapshot_2024_08_13_00'.

Re: How do I locally host a CPAN repository on an air-gapped server
by Corion (Patriarch) on Aug 13, 2024 at 07:15 UTC

    Personally, I also use CPAN::Mini, but there also is Pinto, which aims for fine-grained control of what versions you import into your server. I never got it to run, but I didn't spend much time on it either, since I have a working CPAN::Mini installation already.

    The "downside" of CPAN::Mini is, that it always keeps a complete mirror and always has the latest version. There is very little in customizing distributions or adding your own, internal modules to it. There is CPAN::Mini::Inject for that, but I've never used it.

      CPAN::Mini::Inject works quite well. It has a somewhat strange array of command line options, but they are well explained and easy to understand (just hard to remember).

      The biggest hurdle to get a local CPAN mirror going these days is the regretable descission of some (not top be named here) people regarding the topic "Mirrors are a thing of the past, we'll do everything in our power to curtail the use of CPAN mirrors". That has unfortunately caused the cpan shell to have a somewhat worse support for local mirrors.

      It's been some time since i last my local mirror, but it boiled down to having extra steps to configure the cpan shell, and running (if i remember correctly) into problems with signatures. In that instance, i ended up running a patched version of the cpan shell that disabled some security checks...

      PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
      Also check out my sisters artwork and my weekly webcomics