Sunday, July 18, 2010

cpanminus with CPAN::mini?

At the July Thousand Oaks Perl Mongers [1] open-discussion meeting, we discussed both CPAN::Mini [2],[3] and App::cpanminus [4],[5]. They both work well individually, but can they be combined?

I did an example install of CPAN::Mini[2] for the meeting. This was a learning experience for me, as I'd only briefly heard of it before and this was my first install. CPAN::Mini makes a minimal private mirror of CPAN[6], of all the current release versions of all the CPAN modules! The idea is you keep this mirror up-to-date and anytime you need to install a module, you have it available. To keep the repository more manageable only the current version of each module is mirrored. Installation was super simple, the hardest being polling the room for a preferred CPAN mirror. We settled on ASK's develooper.com.
% cpan CPAN::Mini
% mkdir -p $HOME/mirrors/cpan
% minicpan -L $HOME/mirrors/cpan -R http://cpan.develooper.com/

Tommy then discussed his four favorite modules-of-the-moment for perl5 development and usage, one of which was App::cpanminus[4]. I'd heard of this previously, but hadn't gotten around to testing it. It installs a binary, cpanm[5], that is used to install modules. It tries to just do-the-right-thing, and install modules and keep the output to a minimum. I especially liked the flag to install to a local::lib maintained directory, which is useful in a sudo case where environment variables are annoying to pass.

I then tried to merge the two. First I installed App::cpanminus from my local CPAN::Mini mirror using cpan with the network unplugged. Success!

Then I tried to install a module with cpanm, and found that it was going to the network even though my repo was at a file:// url. Bummer!

I haven't gotten back to testing this, and a brief search found one comment from a user who reverts to cpan to use his CPAN::Mini mirror when he's away from the network. Does anyone have this working? Is it just part of the cpanminus magic that it looks online for the CPAN meta data?

My only reason to teach cpan.pm after that is to support CPAN::Mini and a local CPAN mirror. Thats the only reason I still use CPAN, I'm usually offline.
-- Pedro [7],[8]

Links

Thousand Oaks Perl Mongers
http://thousand-oaks-perl.org
CPAN::Mini
href=http://search.cpan.org/search?q=CPAN::Mini
cpanmini
href=http://search.cpan.org/search?q=minicpan
App::cpanminus
href=http://search.cpan.org/search?q=App::cpanminus
cpanm
href=http://search.cpan.org/search?q=cpanm
C.P.A.N. -- the Comprehensive Perl Archive Network.
http://cpan.org
Pedro
http://www.simplicidade.org/
Modern perl comment
http://www.modernperlbooks.com/mt/2010/04/should-novices-prefer-cpanminus.html#comment-362

1 comment:

miyagawa said...

There's a simple patch on one of github forks to support this. The patch was to fall back to the local mirror index i.e. minicpan index file if its mirror URL is file:///. I've been meaning to merge this in a more generic way so it should work against arbitrary URLs i.e. DarkPAN, not only file:/// URLs but haven't gotten to it yet.