How do I set up a local CPAN mirror?
Solution 1
CPAN::Mini is the way to go. Once you've mirrored CPAN locally, you'll want to set your mirror URL in CPAN.pm or CPANPLUS to the local directory using a "file:" URL like this:
file:///path/to/my/cpan/mirror
If you'd like your mirror to have copies of development versions of CPAN distribution, you can use CPAN::Mini::Devel.
Update:
The "What do I need to mirror CPAN?" FAQ given in another answer is for mirroring all of CPAN, usually to provide another public mirror. That includes old, outdated versions of distributions. CPAN::Mini just mirrors the latest versions. This is much smaller and for most users is generally what people would use for local or disconnected (laptop) access to CPAN.
Solution 2
Besides the other answers, check out Leon's CPAN::Mini::Webserver, which gives you a CPAN Search interface to your local CPAN copy.
If you want to do more fancy things, see my "MyCPAN" talk. You can inject your own private modules into your private CPAN with CPAN::Mini::Inject, for instance.
Solution 3
CPAN::Mini is fine. By default it keeps only the latest version of a distribution, not every version as CPAN does.
You can also install CPAN::Mini::Webserver, which provides you with a web interface to your local cpan mirror - very handy if you are offline and still want to work with perl.
Solution 4
Try CPAN::Mini.
Solution 5
The most likely scenario for running a CPAN mirror is so that your network of 50 machines can all be updated from it locally, instead of hitting the network 50 times.
I'd argue that using CPAN in the traditional manner is a poor way to keep a network of servers up to date.
I run a network of RedHat machines. I package all CPAN modules intended for use in production into RPMs (mostly using the cpanflute2 tool from RPM::Specfile) and deploy them that way, thereby ensuring proper dependency tracking which you don't really get from CPAN itself in any sane way.
Nick Gerakines
Software engineer, author, dad and all around cool guy.
Updated on July 26, 2022Comments
-
Nick Gerakines almost 2 years
What do I need to set up and maintain a local CPAN mirror? What scripts and best practices should I be aware of?
-
brian d foy over 15 yearsOr, if that link disappears because it's tied to a particulr version, try <a href="search.cpan.org/dist/CPAN-Mini">CPAN::Mini</A>. See <a href="stackoverflow.com/questions/43758">How to link to CPAN modules in answers</a> for the discussion of timeless linking. :)
-
Tim Ludwinski over 15 yearsAnd I hope you don't use RedHat's vendor perl? it's full of problematic "fixes" that the perl developers shake their heads about. If we receive a bug report from a RedHat user, the first step is always to verify that it's a problem with perl, not with RedHat. Most of the time it is RedHat.
-
spazm about 13 yearsas of 1.1, search.cpan.org/perldoc?App::cpanminus App::cpanminus (cpanm)</a> supports --mirror-only to pull metadata from your local mirror without querying online. >1.1000 Thu Nov 11 23:56:46 PST 2010 - Added --mirror-only to support minicpan and DarkPAN (jonallen, xdg, tokuhirom)
-
Randal Schwartz almost 9 yearsOr stop using search.cpan.org and use the metacpan (better looking, and open source!): metacpan.org/pod/CPAN::Mini