jeanluca has asked for the
wisdom of the Perl Monks concerning the following question:

Dear Monkshow do I uninstall a package. I just wrote a test package and installed it. But now I would like to remove it. Now that we are discussing un-installing packages/modules, how to uninstall a package with CPAN ?

Problem is that 'install' basically just runs a script, and there's no guarantee that removing all the files listed in the packlist completely removes/uninstalls the package...

Providing an uninstall command might lead users to believe that the results is a 'clean' uninstall, even though that may not be the case. (Nor can it be checked whether it happened).

My personally prefered way to handle perl-packages is to build them, and package them in an RPM. That way, the perl-package can be easily installed and removed using rpm... This preference has probably arrisen because of my sysadmin background; creating one rpm and placing it in a yum or apt repository that all my machines automatically update from is simple and safe way to maintain identical versions on all systems, and allows kickstart installations that include all required perl-packages...

There are various ways to create an rpm package out of a CPAN module. I usually use cpan2rpm. But IIRC, CPANPLUS also includes support for tools like this, and would thereby combine CPAN's power and the (admin) easy of rpm's (or other package styles like .deb).

If you wrote the module yourself, you are the one responsible for providing clean uninstall method for it.

If you used MakeMaker for creating a Makefile (I'm assuming that is what you did), it should create an uninstall target for you, so, if you installed your module with make install, you should be able to uninstall it with make uninstall from module's directory.

Anyway, you should provide more details (how did you install this test module? windoze ppm? perl -MCPAN -e "install Test::Module"? make install?

I just did this because I am a bad boy. I had to install SQLite on an RH9/perl5.8.1 system and it refused! (And said it had duplicate driver files in the tree..). So if you are talking ancient installs and who knows where that came from, watching make won't hack it.

I solved it all by uninstalling DBI and cpan install Bundle::DBI. Whew.

How did I uninstall? Followed the instructions google gave me.. namely search and destroy. In my paranoia I don't destroy and will never know where things should go back if everything breaks, so..

I ran locate DBI.pm to find the various places it hides in the perl tree. At one point I think/hope I did a find . |grep DBI.pm since locate was not up to date but.. okay so I found a bunch of paths ending in DBI.pm.

Basically I renamed all folders called DBI to DBI_old and all DBI.pm files renamed to DBI_old.pm without moving them anywhere. This salved my paranoia (I could grep for DBI_old later on) and my machine is happy. I am wanting to upgrade my perl though.. my other machine is a 5.8.8. (on which various modules like SQL::Statement discover make tests need patching).

Hope this helps. I just pondered the potential merits of saving records of installation sessions on a per-session basis for roll-back but my mind almost melted down. Have a nice day!