CPANM(1)
okay bestie, welcome to CPANM(1) β the manual page for cpanm, aka the iconic little command that gets, unpacks, builds, and installs modules from CPAN. this part is packed, so grab a lil snack πβ¨
πΈ NAME πΈ
cpanm β get, unpack build and install modules from CPAN. no cap, that's the whole mission π«Ά
β¨ SYNOPSIS β¨
here's the vibe check, bestie β look at all these ways to run it:
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 https:/// DBI # use the fast-syncing mirror
cpanm --from https://cpan.metacpan.org/ Plack # use only the HTTPS mirror
π COMMANDS π
okay so 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, fr fr π
π (arguments) π
these all do the thing, bestie:
cpanm Plack
cpanm Plack/Request.pm
cpanm MIYAGAWA/Plack-1.0000.tar.gz
cpanm /path/to/Plack-1.0000.tar.gz
cpanm https:///authors/id/M/MI/MIYAGAWA/Plack-0.9990.tar.gz
cpanm git://github.com/plack/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"". iykyk π
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. noted, bestie β¨
for a git repository, you can specify a branch, tag, or commit SHA to build. the default is master:
cpanm git://github.com/plack/Plack.git@1.0000 # tag
cpanm git://github.com/plack/Plack.git@devel # branch
π«Ά command flags in this section π«Ά
-i,--installβ installs the modules. this is a default behavior and this is just a compatibility option to make it work likecpanorcpanp. slay for consistency π--self-upgradeβ upgrades itself. it's just an alias forcpanm App::cpanminus. self-care, but for the tool π§--infoβ displays the distribution information inAUTHOR/Dist-Name-ver.tar.gzformat in the standard out. cute little info dump β¨--installdepsβ 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 .
deps first, main character later π«Ά
--lookβ download and unpack the distribution and then open the directory with your shell. handy to poke around the source code or do manual testing. literally built for nosy besties π-h,--helpβ displays the help message. when in doubt, ask for help, periodt π-V,--versionβ displays the version number. version check, iconic behavior β
π¦ OPTIONS π¦
you can specify the default options in PERL_CPANM_OPT environment variable. set it once, vibe forever β¨
-f,--forceβ force install modules even when testing failed. bold move, bestie π-n,--notestβ 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-notestto override when it is set in the default options inPERL_CPANM_OPT. speedrun energy, but only when it's earned π₯--test-onlyβ 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. testing era, not installing era π§ͺ-S,--sudoβ switch to the root user withsudowhen installing modules. use this if you want to install modules to the system perl include path. defaults to false, and you can say--no-sudoto override when it is set in the default options inPERL_CPANM_OPT. root mode is highkey serious, so be careful π-v,--verboseβ makes the output verbose. it also enables the interactive configuration. (see--interactive). loud and proud π£οΈ-q,--quietβ makes the output even more quiet than the default. it only shows the successful/failed dependencies to the output. stealth mode activated π€«-l,--local-libβ sets thelocal::libcompatible path to install modules to. you don't need to set this if you already configure the shell environment variables usinglocal::lib, but this can be used to override that as well. local lib, local vibe π-L,--local-lib-containedβ same with--local-libbut with--self-containedset. all non-core dependencies will be installed even if they're already installed. 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:
use local::lib '/path/to/extlib';
π¨ note: this option does NOT reliably work with perl installations supplied by operating system vendors that strips standard modules from perl, such as RHEL, Fedora and CentOS, UNLESS you also install packages supplying all the modules that have been stripped. for these systems you will probably want to install the perl-core meta-package which does just that. read that twice, bestie π
--self-containedβ 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. portable little bundle of joy π--exclude-vendorβ don't include modules installed under the 'vendor' paths when searching for core modules when the--self-containedflag is in effect. this restores the behaviour from before version1.7023. vintage behavior, respectfully π¦--mirrorβ specifies the base URL for the CPAN mirror to use, such ashttps:///(you can omit the trailing slash). you can specify multiple mirror URLs by repeating the command line option. 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 schemefile://. if the given URL begins with/(without any scheme), it is considered as a file scheme as well.
cpanm --mirror file:///path/to/mirror
cpanm --mirror ~/minicpan # Because shell expands ~ to /home/user
defaults to https:///. mirror mirror on the wall, bestie β¨
--mirror-onlyβ download the mirror's02packages.details.txt.gzindex 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). offline era, private era π--from,-Mβ use the given mirror URL and its index as the only source to search and download modules from. it works similar to--mirrorand--mirror-onlycombined, with a small difference: unlike--mirrorwhich appends the URL to the list of mirrors,--from(or-Mfor short) uses the specified URL as its only source to download index and modules from. this makes the option always override the default mirror, which might have been set via global options such as the one set byPERL_CPANM_OPTenvironment variable. tip: it might be useful if you name these options with your shell aliases, like:
alias minicpanm='cpanm --from ~/minicpan'
alias darkpan='cpanm --from http://mycompany.example.com/DPAN'
only source, no distractions. main character mirror energy π
--mirror-indexβ EXPERIMENTAL: specifies the file path to02packages.details.txtfor module search index. experimental, so handle with care π§--cpanmetadbβ EXPERIMENTAL: specifies an alternate URI for CPAN MetaDB index lookups. alternate route, same quest πΊοΈ--metacpanβ prefers MetaCPAN API over CPAN MetaDB. metacpan girlies rise π--cpanfileβ EXPERIMENTAL: specified an alternate path for cpanfile to search for, when--installdepscommand is in use. defaults tocpanfile. cpanfile but make it custom π--promptβ 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-promptto override if it's set in the default options inPERL_CPANM_OPT. interactive queen behavior π--devβ EXPERIMENTAL: search for a newer developer release as well. defaults to false. dev release girlies, this one's for you π--reinstallβ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 --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. reinstall era, no questions asked π
--interactiveβ makes the configuration (such asMakefile.PLandBuild.PL) interactive, so you can answer questions in the distribution that requires custom configuration orTask::distributions. defaults to false, and you can say--no-interactiveto override when it's set in the default options inPERL_CPANM_OPT. talk to it, bestie π«Ά--pp,--pureperlβ prefer Pure perl build of modules by settingPUREPERL_ONLY=1for MakeMaker and--pureperl-onlyfor Build.PL based distributions. note that not all of the CPAN modules support this convention yet. pure perl, pure vibes π§--with-recommends,--with-suggestsβ EXPERIMENTAL: installs dependencies declared asrecommendsandsuggestsrespectively, per META spec. when these dependencies fail to install, cpanm continues the installation, since they're just recommendation/suggestion. enabling this could potentially make a circular dependency for a few modules on CPAN, whenrecommendsadds a module thatrecommendsback the module in return.
π potential circular dependency alert β this is in the original, so don't come for me, bestie. it's giving "mutual recommends" chaos.
there's also --without-recommend and --without-suggests to override the default decision made earlier in PERL_CPANM_OPT. defaults to false for both.
--with-developβ EXPERIMENTAL: installs develop phase dependencies inMETAfiles or incpanfilewhen you use it with--installdeps. Defaults to false. π§ͺ--with-configureβ EXPERIMENTAL: installs configure phase dependencies incpanfilewhen you use it with--installdeps. Defaults to false. π§ͺ--with-featureβ EXPERIMENTAL: specifies the feature to enable, if a module supports optional features per META spec 2.0. Exact example:
cpanm --with-feature=opt_csv Spreadsheet::Read
The features can also be interactively chosen when --interactive is enabled. π
--without-featureβ EXPERIMENTAL: selects a feature to disable. π«--with-all-featuresβ EXPERIMENTAL: enables all the optional features. β¨--configure-timeoutβ sets the timeout length in seconds to wait for the configure process. Current default is60. β³--build-timeoutβ sets the timeout length in seconds to wait for the build process. Current default is3600. β³--test-timeoutβ sets the timeout length in seconds to wait for the test process. Current default is1800. β³
Ok bestie, for the next four *-args options: the argument is only enabled for the module passed as a command line argument, not dependencies. Periodt.
--configure-argsβ EXPERIMENTAL: passes arguments for the configure command, for a given module to install. Example:
cpanm DBD::mysql --configure-args="--cflags=... --libs=..."
--build-argsβ EXPERIMENTAL: passes arguments for the build command, for a given module to install. π οΈ--test-argsβ EXPERIMENTAL: passes arguments for the test command, for a given module to install. π§ͺ--install-argsβ EXPERIMENTAL: passes arguments for the install command, for a given module to install. π¦--scandepsβ DEPRECATED: scans the dependencies of given modules and outputs the tree in a text format. (See--formatbelow for more options.) Because this command doesn't actually install any distributions, it's useful to type:
cpanm --scandeps Catalyst::Runtime
and 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. π
--formatβ DEPRECATED: determines what format to display the scanned dependency tree. Available options aretree,json,yamlanddists.treeβ displays the tree in a plain text format. This is the default value. π³json,yamlβ 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. πͺ
distsβ special output format where it prints the distribution filename in 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. π
--save-distsβ 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 undervendor/Foo-Bar-version.tar.gz. πΎ--uninst-shadowsβ 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. Defaults to true if your perl version is smaller than 5.12, and you can disable that with--no-uninst-shadows.
β οΈ 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.
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. π
--uninstall,-Uβ uninstalls a module from the library path. It finds a packlist for given modules, and removes all the files included in the same distribution. If you enable local::lib, it only removes files from the local::lib directory. If you try to uninstall a module inperldirectory (i.e. core module), an error will be thrown. A dialog will be prompted to confirm the files to be deleted. If you pass-foption as well, the dialog will be skipped and uninstallation will be forced. ποΈ--cascade-searchβ 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. π--skip-installedβ specifies whether a module given in the command line is skipped if its latest version is already installed. Defaults to true.
NOTE: ThePERL5LIBenvironment variable have to be correctly set for this to work with modules installed using local::lib, unless you always use the-loption. π«Ά
--skip-satisfiedβ 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. Defaults to false. β
--verifyβ verifies the integrity of distribution files retrieved from CPAN usingCHECKSUMSfile, andSIGNATURESfile (if found in the distribution). Defaults to false.
β οΈ Using this option does not verify the integrity of the CHECKSUMS file, and it's unsafe to rely on this option if you're using a CPAN mirror that you do not trust. No cap, be careful.
--report-perl-versionβ whether it reports the locally installed perl version to the various web server as part of User-Agent. Defaults to true unless CI related environment variables such asTRAVIS,CIorAUTOMATED_TESTINGis enabled. You can disable it by using--no-report-perl-version. π‘--auto-cleanupβ specifies the number of days in which cpanm's work directories expire. Defaults to7, which means old work directories will be cleaned up in one week. You can set the value to0to make cpan never cleanup those directories. π§Ή--man-pagesβ generates man pages for executables (man1) and libraries (man3). Defaults to true (man pages generated) unless-L|--local-lib-containedoption is supplied, in which case it's set to false. You can disable it with--no-man-pages. π--lwpβ uses LWP module to download stuff over HTTP. Defaults to true, and you can say--no-lwpto disable using LWP, when you want to upgrade LWP from CPAN on some broken perl systems. π--wgetβ uses GNU Wget (if available) to download stuff. Defaults to true, and you can say--no-wgetto disable using Wget (versions of Wget older than 1.9 don't support the--retry-connrefusedoption used by cpanm). π₯--curlβ uses cURL (if available) to download stuff. Defaults to true, and you can say--no-curlto disable using cURL. Normally with--lwp,--wgetand--curloptions set to true (which is the default) cpanm tries LWP, Wget, cURL and HTTP::Tiny (in that order) and uses the first one available. π
πΏ ENVIRONMENT VARIABLES πΏ
PERL_CPANM_HOMEβ the directory cpanm should use to store downloads and build and test modules. Defaults to the.cpanmdirectory in your user's home directory. πPERL_CPANM_OPTβ if set, adds a set of default options to every cpanm command. These options come first, and so are overridden by command-line options. ποΈ
π SEE ALSO π
App::cpanminusβ the whole app itself, iykyk. π
π COPYRIGHT π
Copyright 2010- Tatsuhiko Miyagawa.
βοΈ AUTHOR βοΈ
Tatsuhiko Miyagawa
That's the CPANM(1) tea, bestie: source/version perl v5.42.0, dated 2024-12-12. Mwah! π
ππ¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-App-cpanminus 1.7048-bp160.1.4 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms