How can I remove the Perl module installed via `cpan`?

I use Perl working in user space (not installed via root) and installing modules through the cpan command line. I would like to know if there is an easy way to remove a module without doing a lot of work by deleting individual files.

I searched this question on the Internet and found answers to some questions, but the answers I found either discuss the use of the Perl package manager (for Microsoft Windows), otherwise they are specific to the operating system (BSDpan), offering to use cpanplus (with which I had some unpleasant experiences), or ended up pointing to a dead link as follows: http://www.cpan.org/misc/cpan-faq.html#How_delete_Perl_modules .

My question specifically is whether there is a clean way to remove a module installed through cpan .

+50
module perl cpan
Apr 13 '10 at 1:33
source share
6 answers

You can not. In my CPAN client there is no way to perform such a function. We talked about how we could do something similar this weekend with the Perl QA Workshop, but overall it’s difficult for all the reasons that Ether talked about.

+35
Apr 13 '10 at 6:50
source share
β€” -

Generally, there is no special β€œdelete” mechanism that comes with CPAN modules. But you can try make uninstall in the source directory into which the module is unpacked (this often happens under /root/.cpan or ~/.cpan ), since some packages contain this directive in their installation script. (However, since you installed the modules in the local (non-root) directory of the library, you also have the option of destroying this entire directory and reinstalling everything else that you want to save.)

In most cases, you can just get away with deleting the A/B.pm (for the A::B module) from your perllib - which, at least, makes the module unusable. Most modules also contain a list of files to install (called the "manifest"), so if you can find this, you will know which files you can delete.

However, none of these approaches will address any modules that have been installed as dependencies. There is no good (automated) way to find out if something depends on this module, so you will have to remove it manually as soon as you make sure.

The difficulty of removing modules is one of the reasons many Perl developers want to use version control to track installations β€” for example, see brian d foy's article as an addition to his upcoming book , which discusses the use of git for package management.

+29
Apr 13 2018-10-12T00:
source share
  • Install App::cpanminus from CPAN (use cpan App::cpanminus for this).
  • Type cpanm --uninstall Module::Name (note the " m ") to remove the module using cpanminus.

That should work.

+23
Apr 6 '15 at 9:23
source share

There are scripts in CPAN trying to remove modules:

ExtUtils :: Packlist shows the removal code for the module module module modrm .

+22
Jun 25 '12 at 4:50
source share

Update 2013: This code is deprecated. Upvote bsb late reply .




I don't need to remove modules often, but the .packlist -based .packlist method has never let me down so far.

 use 5.010; use ExtUtils::Installed qw(); use ExtUtils::Packlist qw(); die "Usage: $0 Module::Name Module::Name\n" unless @ARGV; for my $mod (@ARGV) { my $inst = ExtUtils::Installed->new; foreach my $item (sort($inst->files($mod))) { say "removing $item"; unlink $item or warn "could not remove $item: $!\n"; } my $packfile = $inst->packlist($mod)->packlist_file; print "removing $packfile\n"; unlink $packfile or warn "could not remove $packfile: $!\n"; } 
+16
Apr 13 2018-10-10T00:
source share

Since during the installation of a module it basically puts the corresponding .pm files in the appropriate directories. Therefore, if you want to remove the module only for some testing purpose, or in fact it is best to find the path where the module is stored with perldoc -l <MODULE> , and then just move the module from there to another location. This approach can also be considered as a more permanent solution, but I do not know about any negative consequences, since I do this mainly for testing.

+2
May 21 '15 at 5:44
source share



All Articles