Search This Blog

Saturday, March 28, 2009

How to uninstall a CPAN module ?

CPAN module does not have the option of un-installing a perl module as of now. This can be especially frustrating for newbies (as it was for me). I struggled quite a bit on google and found this solution. For this, you need the CPANPLUS module, which needs to be first installed through CPAN.
C:\Users\Pooja Verma>perl -MCPAN -e shell

cpan> install CPANPLUS

cpan> exit

Unlike CPAN, you cannot invoke CPANPLUS by typing cpanplus on command prompt, even if its installed.
C:\Users\Pooja Verma>cpanplus
'cpanplus' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Pooja Verma>perl -MCPANPLUS -e shell
CPANPLUS::Shell::Default -- CPAN exploration and module installation (v0.84)
*** Please report bugs to <bug-cpanplus@rt.cpan.org>.
*** Using CPANPLUS::Backend v0.84.  ReadLine support disabled.

*** Type 'p' now to show start up log

Did you know...
    The documentation in CPANPLUS::Module and CPANPLUS::Backend is very useful
CPAN Terminal> help

[General]
    h | ?                  # display help
    q                      # exit
    v                      # version information
[Search]
    a AUTHOR ...           # search by author(s)
    m MODULE ...           # search by module(s)
    f MODULE ...           # list all releases of a module
    o [ MODULE ... ]       # list installed module(s) that aren't up to date
    w                      # display the result of your last search again
[Operations]
    i MODULE | NUMBER ...  # install module(s), by name or by search number
    i URI | ...            # install module(s), by URI (ie http://foo.com/X.tgz)
    t MODULE | NUMBER ...  # test module(s), by name or by search number
    u MODULE | NUMBER ...  # uninstall module(s), by name or by search number
    d MODULE | NUMBER ...  # download module(s)
    l MODULE | NUMBER ...  # display detailed information about module(s)
    r MODULE | NUMBER ...  # display README files of module(s)
    c MODULE | NUMBER ...  # check for module report(s) from cpan-testers
    z MODULE | NUMBER ...  # extract module(s) and open command prompt in it
[Local Administration]
    b                      # write a bundle file for your configuration
    s program [OPT VALUE]  # set program locations for this session
    s conf    [OPT VALUE]  # set config options for this session
    s mirrors              # show currently selected mirrors

Now you can uninstall the module that you want to. If needed, you can use the --verbose and --force option with it.
CPAN Terminal> u MIME::Head --force --verbose

2 comments:

  1. Thanks!!! I can't imagine why this functionality hasn't been integrated into the CPAN package "manager", but I'm glad someone picked up the torch!

    ReplyDelete