Wednesday, September 16, 2009, Improved

I was just reading a blog post from szabgab and rather than reply directly, I decided I should finally start making posts of my own.

The topic he raises is "CPAN client for beginners" and it's one I've thought about a lot, though not necessarily in the same way.

I've been comfortable with the CPAN shell for a long time, and I know enough about the internals that I have written my own wrappers and automations to drive module retrieval and installation.

My opinion of is that it's a classic case of "It works, so don't fix it" for the Perl community at large... but I think this is a bit of a fallacy.

I'm not particularly interested in a "beginner friendly" CPAN client. I'm far more interested in a *smarter* CPAN client.

Most of the questions the cpan shell asks me when I use it can be, and are auto-detected, properly. Except when I'm not root. And except when I'm running under sudo. Both scenarios seem to me to be pretty easily fixable.

Another place where seems to fall through: picking mirrors. This can also be done automatically, based on latency and bandwidth. I think by default it goes through the redirector so it's probably not a big deal, but even after "auto configuring" it keeps asking me to choose mirrors. Yes, I have a preferred set, and I can easily configure them, but remember, I'm *lazy*.

The third thing I would change about is how it keeps track of installed files. Other package managers can determine if an installed file has been unexpectedly changed - why not Other package managers can tell you from which package (and which version) a file was installed - why not (in regards to the CPAN, package == distribution)

The fourth change, which would be relatively simple if the third were implemented, would be sane uninstall. When upgrading a distribution, the old version's files should be removed! If an author removes a file from a new version, *it should not remain after I upgrade to that version!*

Lastly, and this is probably the most difficult feature I would want, would be the ability to determine *which* distributions (and their versions) are currently installed given an @INC. This would require additional metadata available from the CPAN itself, a sort of super-manifest that the client can download and use to validate and match every file in the include path. I don't think this is something that can be done by any other package management system, but it's nice to dream. :-)

The other things that I would want, well, a lot of that would depend on support in the various build systems and so is probably the topic for another post. Things that would be helpful for newbies are nice, too... but I think a lot of those have already been implemented or solved. Suppressing needless output, a GUI, reporting failed installs to the authors, etc... all either currently have solutions that just need to be integrated or would be fixed with better, friendlier documentation.


  1. I agree with many points of your post. CPAN is cool, but it's far from perfect when talking about usability.

    Probably the point I really miss is the auto-reinstall of modules when I install a new version of core perl, many applications stop working because modules are not compiled for the new one and so on..

  2. I definitely agree there should be an uninstall option. I don't understand why it doesn't exist yet.

  3. @Anonymous: there is already a mechanism for "auto-reinstall" but it is, in my opinion, pretty poorly designed and implemented. It's called "autobundle" and it creates a file listing all the modules you have installed. When you feed this file into another perl installation's cpan client the idea is that it will read that list and install everything in the new instance that you had in the previous. For a plethora of reasons, it doesn't always work.

    @Naveed: There is also a *sort of* uninstall option, but it's unreliable and usually does not work. The reason there is no standard, reliable uninstall option is that the cpan client does not keep enough information about installed files and dists to be able to perform such an action properly.