6

I am Perl beginner. I wanted to use Log::Log4perl module as I am familiar how it works in Java. I used cpanm script to download module, but I ran it without "sudo". Then it installed this module to my dir /home/amer/perl5. Afterwards, I installed it as sudoer, but I want to remove installation in my home dir to avoid any conflicts in future. How can I do that? Here is my cmdline execution stack.

Thanks and Regards!

azec-pdx
  • 205
  • 2
  • 5
  • 9

5 Answers5

7

That's quite experimental for the moment being, but now cpanm supports an uninstall option. From MetaCpan :

-U, --uninstall

EXPERIMENTAL: Uninstalls the modules. Will remove the distribution files from your library path using the .packlist file. When used with -l or -L, only the files under the local::lib directory will be removed. NOTE: If you have the "dual-life" module in multiple locations (i.e. site_perl and perl library path, with perl 5.12 or later), only the files in site_perl will be deleted. If the distribution has bin scripts and man, they will be kept in case the core installation still references that, although there's no guarantee that the script will continue working as expected with the older version of .pm files.

peroumal1
  • 171
  • 1
  • 3
1

Try App::pmuninstall

DESCRIPTION

App::pmuninstall is a fast module uninstaller. delete files from .packlist.

App::cpanminus and, App::cpanoutdated with a high affinity.

bor
  • 21
  • 2
0

From your user account go to shell/command prompt, enter PPM. When PPM opens type "remove [package name]" this will uninstall that particular package for you. type "help remove" in PPM for more details.

JonnyJD
  • 361
  • 3
  • 13
Chakri
  • 1,070
  • 6
  • 8
0

I have tried App::pmuninstall and it is worked for me fine.

Install module using command:

$ perl -MCPAN -e shell

Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.

cpan[1]>install App::pmuninstall

...

cpan[2]>quit

Usage.

On my local machine it has installed to /home/taras/perl5/bin/pm-uninstall

pm-uninstall [options] Module ...

options:

    -v,--verbose                  Turns on chatty output
    -f,--force                    Uninstalls without prompts
    -c,--checkdeps                Check dependencies (defaults to on)
    -n,--no-checkdeps             Don't check dependencies
    -q,--quiet                    Suppress some messages
    -h,--help                     This help message
    -V,--version                  Show version
    -l,--local-lib                Additional module path
    -L,--local-lib-contained      Additional module path (don't include non-core modules)

Module website is: https://metacpan.org/release/App-pmuninstall

Taras
  • 228
  • 1
  • 2
  • 8
-1

I used David Farrell's script:

#!/usr/bin/perl
# uninstall_perl_module.pl from PerlTricks.com

use 5.14.2;
use ExtUtils::Installed;
use ExtUtils::Packlist;

# Exit unless a module name was passed
die ("Error: no Module::Name passed as an argument. E.G.\n\t perl $0 Module::Name\n") unless $#ARGV == 0;

my $module = shift @ARGV;

my $installed_modules = ExtUtils::Installed->new;

# iterate through and try to delete every file associated with the module
foreach my $file ($installed_modules->files($module)) {
    print "removing $file\n";
    unlink $file or warn "could not remove $file: $!\n";
}

# delete the module packfile
my $packfile = $installed_modules->packlist($module)->packlist_file;
print "removing $packfile\n";
unlink $packfile or warn "could not remove $packfile: $!\n";

# delete the module directories if they are empty
foreach my $dir (sort($installed_modules->directory_tree($module))) {
    print("removing $dir\n");
    rmdir $dir or warn "could not remove $dir: $!\n";
}

It did the job although it produced some scary looking output :-):

removing /
could not remove /: Device or resource busy
removing /home
could not remove /home: Permission denied

You might also want to have a look at this post.

jreisinger
  • 215
  • 2
  • 3
  • 9