Tatsuhiko Miyagawa's blog to discuss mostly tech and nerdy stuff.

2010.11.12

cpanm 1.1 hearts minicpan and darkpan

cpanm 1.1 is shipped, and with `--mirror-only` option, you can use it with your local minicpan mirror, or your own company's CPAN index (aka DarkPAN).

The only reason for a few experienced perl programmers who loves cpanm but can't use cpanm offline or at work was the lack of the proper mirror index querying support.

cpanm always has required an internet connection to resolve module name and dependencies, and always relies on CPAN Meta DB and search.cpan.org to query package index.

It's been a fair requirement for 95% of the usage, but again, for an experienced hacker who spends their most of airplane's time hacking code on their laptops, the offline support to fallback to local minicpan would be really nice. (Even though many airlines nowadays provide in-flight Wi-Fi :))

So I opened a bug to support `--mirror-only` option to bypass these internet queries and parse mirror's own 02packages.txt.gz file for module resolution a while ago, and a couple of people have tried implementing it in their own branches. (Thank you!)

Today I merged one of those implementations, and improved a little bit to make it run even faster and more network efficient. The way to use it is really simple, just run cpanm with options such as:

cpanm --mirror ~/minicpan --mirror-only Plack

and it will use your minicpan local mirror as the only place to resolve module names and download tarballs from. (TIP: you can alias this like `minicpanm` to save typing)

The current code extracts the gzipped file and reads the whole in memory and does a quick regular expression, which is very fast and not /that/ RAM hoggy (02packages is like 6MB file when uncompressed), but i hope this could be improved to be even more RAM efficient and still fast enough in the upcoming 1.1.x releases.

This is a huge step in cpanm history and makes it even more useful. You can upgrade your cpanm to the latest version by running `cpanm --self-upgrade`.