« Finally: new website design | Main | September 11, 2005 »

September 08, 2005

Dumb software: CPAN

CPAN is the Comprehensive Perl Archive Network, and it's a huge repository of perl modules covering an enormous array of computing needs. It's an amazing resource and one of the best features of perl.

The client side is the cpan command, which can find and install requested modules, and it knows about and offers to install dependencies:

# cpan
cpan shell -- CPAN exploration and modules installation 
cpan> install HTML::Foo

I'm taking a look at the RT ticketing system, and it has a long list of requirements. This is exactly what CPAN was meant for. But as I installed package after package, it kept trying to install the junoscript-perl package each time. Huh? This package is used for talking with Juniper routers, and is reportedly excellent, but I'd not requested it. Hmmm.

We do use Juniper routers, so perhaps this is stuck in a cache somewhere, so I looked all over the system and killed any reference to junoscript. It kept coming back. WTF?

Several hours later I figured it out: in addition to the shell version, one can launch an install directly on the command line, and I'd been using:

$ cpan install HTML::Foo        surprise!

Well guess what: install is not a keyword on the command line, it's the name of a package or module, and cpan located a package in its directory that provides the install module. This directory is found in the .cpan/sources/modules/02packages.details.txt file, and it contains:

...
INSPEC::BibTeX     0.01 V/VP/VPLA/INSPEC-0.01.tar.gz
INSPEC::Retriever  0.01 V/VP/VPLA/INSPEC-0.01.tar.gz
install           undef J/JU/JUNOS/junoscript-perl-6.4I0.tar.gz
integer            1.00 N/NW/NWCLARK/perl-5.8.6.tar.gz
interface          0.02 S/SW/SWALTERS/interface-0.02.tar.gz
...

So junoscript is providing an install module, and this is what I was asking for. Over and over. For hours. The proper syntax is:

$ cpan HTML::Foo                correct

This was technically my fault — I used the wrong syntax — but this is a clear violation of the Principle of Least Astonishment, and I can't believe how frustrating this was. A bit of google shows that I'm not the only one who's had this problem either.

Why isn't this a keyword, or at least have the install module removed from Junoscript?

Posted by steve at September 8, 2005 05:42 AM

Trackback Pings

TrackBack URL for this entry:
http://www.unixwiz.net/mt/trackback/47

Comments

Ah ha!

I've run into this countless times and couldn't figure out WTF CPAN was smoking.

Thanks!

Posted by: Jeremy Zawodny at September 8, 2005 07:28 AM

Heh heh, CPAN be teh suck sometimes.

Posted by: Sandeep at September 9, 2005 07:17 AM

Wow! Thank you for this information. I can't believe how annoying this has been! You're right. Either "install" needs to be ignored by cpan or install doesn't need to be used as the name of a module on CPAN. *sigh*

Posted by: Jim at July 11, 2006 12:26 PM

None of the CPAN.pm shell commands are options for the cpan(1) tool. I could add "install" as a special word, but that doesn't clear up Least Antonishment, since none of the other valid commands from CPAN.pm will work from cpan(1). A tool that specially handles "install" needs a completely different interface to be consistent. To handle that, most of the code in cpan(1) has to be changed since argument processing becomes a lot more complicated for the arguments without leading dashes (and for long arguments).

In general, when a tool is doing something you don't think it should do, try reading its documentation. :)

Posted by: brian d foy at August 17, 2006 11:31 AM

I've had this same problem for a while, and in fact I've only just now become aware that 'install' didn't do what I thought it did; all I ever do with cpan(1) is install modules or start the CPAN shell, and I never looked any more deeply at it than that.

So now what I want to know is: where did I (and apparently a decent number of other people) get the idea that 'cpan install HTML::Foo' is the correct syntax?

Posted by: Aaron at September 19, 2006 01:13 PM