LinuxCommandLibrary

cpanm

TLDR

Install a Perl module

$ cpanm [Module::Name]
copy
Install module locally (without root)
$ cpanm -l ~/perl5 [Module::Name]
copy
Install from cpanfile
$ cpanm --installdeps .
copy
Install specific version
$ cpanm [Module::Name]@[1.23]
copy
Install from Git repository
$ cpanm [git://github.com/user/repo.git]
copy
Uninstall a module
$ cpanm -U [Module::Name]
copy
Show what would be installed
$ cpanm --info [Module::Name]
copy
Install quietly
$ cpanm -q [Module::Name]
copy

SYNOPSIS

cpanm [options] Module...

DESCRIPTION

cpanm (cpanminus) is a script to install Perl modules from CPAN (Comprehensive Perl Archive Network). It provides a simpler, faster alternative to the traditional CPAN shell with minimal dependencies and configuration.
The tool automatically resolves and installs dependencies, downloads modules from CPAN mirrors, runs tests, and installs to the appropriate location. It supports local::lib for user-local installations without root privileges.
cpanm can install modules by name, from tarballs, from Git repositories, or from URLs. The cpanfile format allows declaring project dependencies that cpanm can install with --installdeps.

PARAMETERS

-l, --local-lib path

Install modules to local directory.
-L, --local-lib-contained path
Install to directory with contained dependencies.
-n, --notest
Skip running tests.
-q, --quiet
Quiet output.
-v, --verbose
Verbose output.
-f, --force
Force install even if tests fail.
-U, --uninstall
Uninstall module.
--installdeps
Install dependencies only.
--info
Show module information without installing.
--look
Download and unpack, then open shell.
--mirror url
CPAN mirror URL.
--sudo
Use sudo for installation.

CAVEATS

Installing globally requires root privileges unless using local::lib. Some modules have system dependencies (libraries, headers) that must be installed separately. Test failures may indicate incompatible system configurations. The --notest flag should be used cautiously as it may install broken modules.

HISTORY

cpanminus was created by Tatsuhiko Miyagawa in 2010 as a zero-configuration CPAN installer. Frustrated with the complexity of CPAN.pm and CPANPLUS, he designed cpanm to "just work" with sensible defaults. It became the de facto standard for installing Perl modules, valued for its simplicity and speed.

SEE ALSO

cpan(1), carton(1), perl(1), local::lib(3pm)

Copied to clipboard