CPAN(1)
π cpan β the CPAN(1) manual but make it make sense
okay bestie, gather round, because this page is literally the glow-up your command line has been waiting for π«Ά
β¨ NAME β¨
cpan β easily interact with CPAN from the command line
πΈ SYNOPSIS πΈ
# with arguments and no switches, installs specified modules
cpan module_name [ module_name ... ]
# with switches, installs modules with extra behavior
cpan [-cfFimtTw] module_name [ module_name ... ]
# use local::lib
cpan -I module_name [ module_name ... ]
# one time mirror override for faster mirrors
cpan -p ...
# with just the dot, install from the distribution in the
# current directory
cpan .
# without arguments, starts CPAN.pm shell
cpan
# without arguments, but some switches
cpan [-ahpruvACDLOPX]
π¦ DESCRIPTION π¦
So this script is a command interface β a command interface, not a shell, okay, we're keeping those two separate β to CPAN. Right now it's using CPAN.pm to do all the actual heavy lifting, but heads up: it is not a one-shot command runner for CPAN.pm. Different vibe entirely. π
π Options π
-aβ makes a CPAN.pm autobundle withCPAN::Shell->autobundle.-Amodule [ module ... ] β shows you the primary maintainers for the modules you named. π-cmodule β runs amake cleanin the specified module's directories.-Cmodule [ module ... ] β shows the Changes files for the modules you named.-Dmodule [ module ... ] β shows the module details. It prints one line for each out-of-date module (and by "out-of-date" we mean modules installed locally that have newer versions up on CPAN). Every line has three columns: module name, local version, and CPAN version. π-fβ forces the specified action when it would normally have failed. Use it to install a module even if its tests fail. And listen: when you use this option,-iis not optional for installing a module when you need to force it:
% cpan -f -i Module::Foo
-Fβ turns off CPAN.pm's attempts to lock anything. Be careful with this one, bestie, because you could end up with multiple scripts trying to muck around in the same directory. It's less of a concern if you're loading a special config with-jand that config sets up its own work directories.-gmodule [ module ... ] β downloads the latest distribution of the module to the current directory.-Gmodule [ module ... ] β UNIMPLEMENTED. The idea: download the latest distribution of the modules to the current directory, unpack each distribution, and create a git repository for each distribution. If you actually want this feature, go check out Yanick Champoux'sGit::CPAN::Patchdistribution.-hβ prints a help message and exits. When you specify-h, it ignores all of the other options and arguments. iconic behaviour honestly.-imodule [ module ... ] β installs the specified modules. With no other switches, this switch is implied.-Iβ loadslocal::lib(think of it like-Ifor loading lib paths). Too bad-lwas already taken. π-jConfig.pm β loads the file that has the CPAN configuration data. It should have the same format as the standardCPAN/Config.pmfile, which defines$CPAN::Configas an anonymous hash.-Jβ dumps the configuration in the same format that CPAN.pm uses. Super useful for checking your config, and also for using the dump as a starting point for a new, custom configuration.-lβ lists all installed modules with their versions.-Lauthor [ author ... ] β lists the modules by the specified authors.-mβ makes the specified modules.-Mmirror1,mirror2,... β a comma-separated list of mirrors to use for just this run. The-Poption can find them for you automatically. β¨-nβ do a dry run, but don't actually install anything. (unimplemented)-Oβ shows the out-of-date modules.-pβ pings the configured mirrors and prints a report.-Pβ finds the best mirrors you could be using and uses them for the current session.-rβ recompiles dynamically loaded modules withCPAN::Shell->recompile.-sβ drops you into the CPAN.pm shell. This command does it automatically if you don't specify any arguments.-tmodule [ module ... ] β runs amake teston the specified modules.-Tβ do not test modules. Just install them. no thoughts, just install π-uβ upgrades all installed modules. Doing this blindly can really break things, so keep a backup. fr fr, back it up.-vβ prints the script version and CPAN.pm version, then exits.-Vβ prints detailed information about the cpan client.-wβ UNIMPLEMENTED. The idea was to turn on cpan warnings: it checks various things, like directory permissions, and tells you about problems you might have.-xmodule [ module ... ] β finds close matches to the named modules that you think you might have mistyped. This one requires the optional installation ofText::LevenshteinorText::Levenshtein::Damerau.-Xβ dumps all the namespaces to standard output.
π Examples π
# print a help message
cpan -h
# print the version numbers
cpan -v
# create an autobundle
cpan -a
# recompile modules
cpan -r
# upgrade all installed modules
cpan -u
# install modules ( sole -i is optional )
cpan -i Netscape::Booksmarks Business::ISBN
# force install modules ( must use -i )
cpan -fi CGI::Minimal URI
# install modules but without testing them
cpan -Ti CGI::Minimal URI
π§ Environment variables π§
There are several components in CPAN.pm that use environment variables. The build tools, ExtUtils::MakeMaker and Module::Build, use some, while others matter to the levels above them. Some of these are specified by the Perl Toolchain Gang:
Lancaster Concensus: <https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md>
Oslo Concensus: <https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md>
NONINTERACTIVE_TESTINGβ assume no one is paying attention, and skip prompts for distributions that do that correctly. cpan(1) sets this to1unless it already has a value (even if that value is false).PERL_MM_USE_DEFAULTβ use the default answer for prompted questions. cpan(1) sets this to1unless it already has a value (even if that value is false).CPAN_OPTSβ as withPERL5OPT, a string of additional cpan(1) options to add to those you specify on the command line.CPANSCRIPT_LOGLEVELβ the log level to use, with either the embedded, minimal logger orLog::Log4perlif it is installed. Possible values are the same as theLog::Log4perllevels:TRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.GIT_COMMANDβ the path to thegitbinary to use for the Git features. The default is/usr/local/bin/git.
β EXIT VALUES β
The script exits with zero if it thinks that everything worked, or a positive number if it thinks that something failed. But ngl, in some cases it has to divine a failure by the output of things it does not control. For now, the exit codes are vague:
1 An unknown error
2 The was an external problem
4 There was an internal problem with the script
8 A module failed to install
π TO DO π
- one shot configuration values from the command line
π BUGS π
- none noted
π SEE ALSO π
Most behaviour, including environment variables and configuration, comes directly from CPAN.pm.
π SOURCE AVAILABILITY π
This code is in Github in the CPAN.pm repository:
https://github.com/andk/cpanpm
The source used to be tracked separately in another GitHub repo, but the canonical source is now in the above repo. periodt.
π CREDITS π
Japheth Cleaver added the bits to allow a forced install (-f).
Jim Brandt suggest and provided the initial implementation for the up-to-date and Changes features.
Adam Kennedy pointed out that exit() causes problems on Windows where this script ends up with a .bat extension.
π AUTHOR π
brian d foy, "<bdfoy@cpan.org>"
π COPYRIGHT π
Copyright (c) 2001-2015, brian d foy, All Rights Reserved.
You may redistribute this under the same terms as Perl itself.
and that's the whole page, bestie π«Ά this one's from perl v5.34.0, dated 2026-09-03, and yeah the manual name up top is CPAN(1) β slay, you read the whole thing, so proud of you πβ¨
π¦ where this page comes from
- ubuntu jammy: libperl5.34 5.34.0-3ubuntu1.9 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms