cpanm - get, unpack build and install modules from CPAN
cpanm Test::More # install Test::More cpanm MIYAGAWA/Plack-0.99_05.tar.gz # full distribution path cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz # install from URL cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz # install from a local file cpanm --interactive Task::Kensho # Configure interactively cpanm . # install from local directory cpanm --installdeps . # install all the deps for the current directory cpanm -L extlib Plack # install Plack and all non-core deps into extlib cpanm --mirror http://cpan.cpantesters.org/ DBI # use the fast-syncing mirror cpanm --scandeps Moose # See what modules will be installed for Moose
Command line arguments can be either a module name, distribution file, local file path, HTTP URL or git repository URL. Following commands will all work as you expect.
cpanm Plack cpanm Plack/Request.pm cpanm MIYAGAWA/Plack-1.0000.tar.gz cpanm /path/to/Plack-1.0000.tar.gz cpanm http://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/Plack-0.9990.tar.gz cpanm git://github.com/miyagawa/Plack.git
Additionally, you can use the notation using ~ and @ to specify version for a given module. ~ specifies the version requirement in the CPAN::Meta::Spec format, while @ pins the exact version, and is a shortcut for ~"== VERSION".
~
@
~"== VERSION"
cpanm Plack~1.0000 # 1.0000 or later cpanm Plack~">= 1.0000, < 2.0000" # latest of 1.xxxx cpanm Plack@0.9990 # specific version. same as Plack~"== 0.9990"
The version query including specific version or range will be sent to MetaCPAN to search for previous releases. The query will search for BackPAN archives by default, unless you specify --dev option, in which case, archived versions will be filtered out.
--dev
For a git repository, you can specify a branch, tag, or commit SHA to build. The default is master
master
cpanm git://github.com/miyagawa/Plack.git@1.0000 # tag cpanm git://github.com/miyagawa/Plack.git@devel # branch
Installs the modules. This is a default behavior and this is just a compatibility option to make it work like cpan or cpanp.
Upgrades itself. It's just an alias for:
cpanm App::cpanminus
Displays the distribution information in AUTHOR/Dist-Name-ver.tar.gz format in the standard out.
AUTHOR/Dist-Name-ver.tar.gz
Installs the dependencies of the target distribution but won't build itself. Handy if you want to try the application from a version controlled repository such as git.
cpanm --installdeps .
Download and unpack the distribution and then open the directory with your shell. Handy to poke around the source code or do manual testing.
Displays the help message.
Displays the version number.
You can specify the default options in PERL_CPANM_OPT environment variable.
PERL_CPANM_OPT
Force install modules even when testing failed.
Skip the testing of modules. Use this only when you just want to save time for installing hundreds of distributions to the same perl and architecture you've already tested to make sure it builds fine.
Defaults to false, and you can say --no-notest to override when it is set in the default options in PERL_CPANM_OPT.
--no-notest
Run the tests only, and do not install the specified module or distributions. Handy if you want to verify the new (or even old) releases pass its unit tests without installing the module.
Note that if you specify this option with a module or distribution that has dependencies, these dependencies will be installed if you don't currently have them.
Switch to the root user with sudo when installing modules. Use this if you want to install modules to the system perl include path.
sudo
Defaults to false, and you can say --no-sudo to override when it is set in the default options in PERL_CPANM_OPT.
--no-sudo
Makes the output verbose. It also enables the interactive configuration. (See --interactive)
Makes the output even more quiet than the default. It doesn't print anything to the STDERR.
Sets the local::lib compatible path to install modules to. You don't need to set this if you already configure the shell environment variables using local::lib, but this can be used to override that as well.
Same with --local-lib but with --self-contained set. All non-core dependencies will be installed even if they're already installed.
--local-lib
For instance,
cpanm -L extlib Plack
would install Plack and all of its non-core dependencies into the directory extlib, which can be loaded from your application with:
extlib
use local::lib '/path/to/extlib';
When examining the dependencies, assume no non-core modules are installed on the system. Handy if you want to bundle application dependencies in one directory so you can distribute to other machines.
Specifies the base URL for the CPAN mirror to use, such as http://cpan.cpantesters.org/ (you can omit the trailing slash). You can specify multiple mirror URLs by repeating the command line option.
http://cpan.cpantesters.org/
You can use a local directory that has a CPAN mirror structure (created by tools such as OrePAN or Pinto) by using a special URL scheme file://. If the given URL begins with `/` (without any scheme), it is considered as a file scheme as well.
file://
cpanm --mirror file:///path/to/mirror cpanm --mirror ~/minicpan # Because shell expands ~ to /home/user
Defaults to http://search.cpan.org/CPAN which is a geo location aware redirector.
http://search.cpan.org/CPAN
Download the mirror's 02packages.details.txt.gz index file instead of querying the CPAN Meta DB. This will also effectively opt out sending your local perl versions to backend database servers such as CPAN Meta DB and MetaCPAN.
Select this option if you are using a local mirror of CPAN, such as minicpan when you're offline, or your own CPAN index (a.k.a darkpan).
Tip: It might be useful if you name these mirror options with your shell aliases, like:
alias minicpanm='cpanm --mirror ~/minicpan --mirror-only' alias darkpan='cpanm --mirror http://mycompany.example.com/DPAN --mirror-only'
EXPERIMENTAL: Specifies the file path to 02packages.details.txt for module search index.
02packages.details.txt
Prompts when a test fails so that you can skip, force install, retry or look in the shell to see what's going wrong. It also prompts when one of the dependency failed if you want to proceed the installation.
Defaults to false, and you can say --no-prompt to override if it's set in the default options in PERL_CPANM_OPT.
--no-prompt
EXPERIMENTAL: search for a newer developer release as well. Defaults to false.
cpanm, when given a module name in the command line (i.e. cpanm Plack), checks the locally installed version first and skips if it is already installed. This option makes it skip the check, so:
cpanm Plack
cpanm --reinstall Plack
would reinstall Plack even if your locally installed version is latest, or even newer (which would happen if you install a developer release from version control repositories).
Defaults to false.
Makes the configuration (such as Makefile.PL and Build.PL) interactive, so you can answer questions in the distribution that requires custom configuration or Task:: distributions.
Makefile.PL
Build.PL
Defaults to false, and you can say --no-interactive to override when it's set in the default options in PERL_CPANM_OPT.
--no-interactive
Scans the depencencies of given modules and output the tree in a text format. (See --format below for more options)
--format
Because this command doesn't actually install any distributions, it will be useful that by typing:
cpanm --scandeps Catalyst::Runtime
you can make sure what modules will be installed.
This command takes into account which modules you already have installed in your system. If you want to see what modules will be installed against a vanilla perl installation, you might want to combine it with -L option.
-L
Determines what format to display the scanned dependency tree. Available options are tree, json, yaml and dists.
tree
json
yaml
dists
Displays the tree in a plain text format. This is the default value.
Outputs the tree in a JSON or YAML format. JSON and YAML modules need to be installed respectively. The output tree is represented as a recursive tuple of:
[ distribution, dependencies ]
and the container is an array containing the root elements. Note that there may be multiple root nodes, since you can give multiple modules to the --scandeps command.
--scandeps
dists is a special output format, where it prints the distribution filename in the depth first order after the dependency resolution, like:
GAAS/MIME-Base64-3.13.tar.gz GAAS/URI-1.58.tar.gz PETDANCE/HTML-Tagset-3.20.tar.gz GAAS/HTML-Parser-3.68.tar.gz GAAS/libwww-perl-5.837.tar.gz
which means you can install these distributions in this order without extra dependencies. When combined with -L option, it will be useful to replay installations on other machines.
Specifies the optional directory path to copy downloaded tarballs in the CPAN mirror compatible directory structure i.e. authors/id/A/AU/AUTHORS/Foo-Bar-version.tar.gz
If the distro tarball did not come from CPAN, for example from a local file or from GitHub, then it will be saved under vendor/Foo-Bar-version.tar.gz.
Uninstalls the shadow files of the distribution that you're installing. This eliminates the confusion if you're trying to install core (dual-life) modules from CPAN against perl 5.10 or older, or modules that used to be XS-based but switched to pure perl at some version.
If you run cpanm as root and use INSTALL_BASE or equivalent to specify custom installation path, you SHOULD disable this option so you won't accidentally uninstall dual-life modules from the core include path.
INSTALL_BASE
Defaults to true if your perl version is smaller than 5.12, and you can disable that with --no-uninst-shadows.
--no-uninst-shadows
NOTE: Since version 1.3000 this flag is turned off by default for perl newer than 5.12, since with 5.12 @INC contains site_perl directory before the perl core library path, and uninstalling shadows is not necessary anymore and does more harm by deleting files from the core library path.
EXPERIMENTAL: Specifies whether to cascade search when you specify multiple mirrors and a mirror doesn't have a module or has a lower version of the module than requested. Defaults to false.
Specifies whether a module given in the command line is skipped if its latest version is already installed. Defaults to true.
NOTE: The PERL5LIB environment variable have to be correctly set for this to work with modules installed using local::lib.
PERL5LIB
EXPERIMENTAL: Specifies whether a module (and version) given in the command line is skipped if it's already installed.
If you run:
cpanm --skip-satisfied CGI DBI~1.2
cpanm won't install them if you already have CGI (for whatever versions) or have DBI with version higher than 1.2. It is similar to --skip-installed but while --skip-installed checks if the latest version of CPAN is installed, --skip-satisfied checks if a requested version (or not, which means any version) is installed.
--skip-installed
--skip-satisfied
Verify the integrity of distribution files retrieved from PAUSE using CHECKSUMS and SIGNATURES (if found). Defaults to false.
Whether it report the locally installed perl version to the various web server as part of User-Agent. Defaults to true, and you can disable it by using --no-report-perl-version.
--no-report-perl-version
Specifies the number of days in which cpanm's work directories expire. Defaults to 7, which means old work directories will be cleaned up in one week.
You can set the value to 0 to make cpan never cleanup those directories.
0
Generates man pages for executables (man1) and libraries (man3).
Defaults to false (no man pages generated) if -L|--local-lib-contained option is supplied. Otherwise, defaults to true, and you can disable it with --no-man-pages.
-L|--local-lib-contained
--no-man-pages
Uses LWP module to download stuff over HTTP. Defaults to true, and you can say --no-lwp to disable using LWP, when you want to upgrade LWP from CPAN on some broken perl systems.
--no-lwp
Uses GNU Wget (if available) to download stuff. Defaults to true, and you can say --no-wget to disable using Wget (versions of Wget older than 1.9 don't support the --retry-connrefused option used by cpanm).
--no-wget
--retry-connrefused
Uses cURL (if available) to download stuff. Defaults to true, and you can say --no-curl to disable using cURL.
--no-curl
Normally with --lwp, --wget and --curl options set to true (which is the default) cpanm tries LWP, Wget, cURL and HTTP::Tiny (in that order) and uses the first one available.
--lwp
--wget
--curl
App::cpanminus
Copyright 2010 Tatsuhiko Miyagawa.
Tatsuhiko Miyagawa
To install App::cpanminus, copy and paste the appropriate command in to your terminal.
cpanm
CPAN shell
perl -MCPAN -e shell install App::cpanminus
For more information on module installation, please visit the detailed CPAN module installation guide.