App::Cpan(3perl)
π App::Cpan β the cpan command, but make it make sense π
okay bestie, so this is the manual page for App::Cpan π
(that's the module behind the cpan command you keep typing). It lives in the Perl Programmers Reference Guide, and it's basically the group chat between you and CPAN. sit down, grab a strawberry drink π, we're doing this.
β¨ NAME β¨
App::Cpan β easily interact with CPAN from the command line. that's it, that's the whole vibe. no cap. π«Ά
π 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 gives you a command interface to CPAN β and no, bestie, it is not a shell (well, it can drop you into one, but that's a whole thing, we'll get there π). Right now it uses CPAN.pm to do the actual work, but it is not a one-shot command runner for CPAN.pm. it's its own whole icon. β¨
π Options π
-aβ creates aCPAN.pmautobundle withCPAN::Shell->autobundle. iconic behavior honestly.-Amodule [ module ... ] β shows you the primary maintainers for the modules you named. who's running this account π-cmodule β runs amake cleanin the specified module's directories. tidy up, we love a clean girl πΈ-Cmodule [ module ... ] β show the Changes files for the specified modules. the receipts, the lore π-Dmodule [ module ... ] β show the module details. this prints one line for each out-of-date module (meaning: modules you have locally, but there are newer versions up on CPAN). each line has three columns: module name, local version, and CPAN version. three columns, no notes π-fβ force the specified action, even when it normally would have failed. use this 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β turn offCPAN.pm's attempts to lock anything. β οΈ you should be careful with this since you might end up with multiple scripts trying to muck in the same directory. it's not so much of a concern if you're loading a special config with-j, and that config sets up its own work directories.-gmodule [ module ... ] β downloads the latest distribution of the module to the current directory. just the download, no install. window shopping ποΈ-Gmodule [ module ... ] β UNIMPLEMENTED. π supposed to download the latest distribution of the modules to the current directory, unpack each distribution, and create a git repository for each distribution. if you want this feature, check out Yanick Champoux'sGit::CPAN::Patchdistribution.-hβ print a help message and exit. and when you specify-h, it ignores all of the other options and arguments.-hsaid main character energy only, everyone else go home π-imodule [ module ... ] β install the specified modules. with no other switches, this switch is implied. it's giving "you didn't even have to ask" π-Iβ loadlocal::lib(think like-Ifor loading lib paths). too bad-lwas already taken. π-jConfig.pm β load the file that has the CPAN configuration data. this should have the same format as the standardCPAN/Config.pmfile, which defines$CPAN::Configas an anonymous hash. if the file does not exist,cpandies. π no file, no vibes.-Jβ dump the configuration in the same format thatCPAN.pmuses. super useful for checking the configuration and for using the dump as a starting point for a new, custom configuration. reuse, recycle, slay β»οΈ-lβ list all installed modules with their versions. the roll call π-Lauthor [ author ... ] β list the modules by the specified authors. the author's whole catalog π-mβ make the specified modules. building, not installing π¨-Mmirror1,mirror2,... β a comma-separated list of mirrors to use for just this run. and the-Poption can find them for you automatically. one-time mirror, no commitment π«-nβ do a dry run, but don't actually install anything. (unimplemented) π«-Oβ show the out-of-date modules. who's falling behind, no judgement π-pβ ping the configured mirrors and print a report. mirror wellness check π©Ί-Pβ find the best mirrors you could be using, and use them for the current session. glow up your mirrors β¨-rβ recompiles dynamically loaded modules withCPAN::Shell->recompile. refresh, reboot, recompile π-sβ drop in theCPAN.pmshell. this command does this automatically if you don't specify any arguments. so like,cpanwith nothing is already this π-tmodule [ module ... ] β run amake teston the specified modules. test, don't trust π§ͺ-Tβ do not test modules. simply install them. living dangerously, we respect it π-uβ upgrade all installed modules. β οΈ blindly doing this can really break things, so keep a backup. seriously bestie, back it up. fr fr.-vβ print the script version andCPAN.pmversion, then exit. the ID check πͺͺ-Vβ print detailed information about thecpanclient. the full biopsy π©»-wβ UNIMPLEMENTED. π supposed to turn on cpan warnings: this checks various things, like directory permissions, and tells you about problems you might have.-xmodule [ module ... ] β find close matches to the named modules that you think you might have mistyped. this requires the optional installation ofText::LevenshteinorText::Levenshtein::Damerau. typos happen, live laugh love π¦-Xβ dump all the namespaces to standard output. every single one. information overload, we love π
πΈ 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 Consensus:
https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md
Oslo Consensus:
https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md
NONINTERACTIVE_TESTINGβ assume no one is paying attention and skips 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 a 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 additionalcpan(1)options to add to those you specify on the command line. secret bonus settings π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.
π Methods π
run( ARGS )β just do it. π€
The run method returns 0 on success and a positive number on failure. see the section on EXIT CODES for details on the values.
CPAN.pm sends all the good stuff either to STDOUT, or to a temp file if $CPAN::Be_Silent is set. I have to intercept that output so I can find out what happened.
Stolen from File::Path::Expand. (borrowed with love π«Ά)
π₯ EXIT VALUES π₯
The script exits with zero if it thinks that everything worked, or a positive number if it thinks that something failed. Note, however, that 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 error2β The was an external problem4β There was an internal problem with the script8β A module failed to install
(and yes, "The was an external problem" is what the original says. typo stays, I don't make the rules π)
β TO DO β
- There is initial support for Log4perl if it is available, but I haven't gone through everything to make the NullLogger work out correctly if Log4perl is not installed.
- When I capture
CPAN.pmoutput, I need to check for errors and report them to the user. - Warnings switch
- Check then exit
the list is giving "we'll get to it" energy β¨
π BUGS π
- none noted
we love a flawless queen. no cap. π
π SEE ALSO π
CPAN, App::cpanminus
π 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. canon is canon, bestie π
π«Ά CREDITS π«Ά
- Japheth Cleaver added the bits to allow a forced install (
-f). - Jim Brandt suggested 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.batextension - David Golden helps integrate this into the
CPAN.pmrepos. - Jim Keenan fixed up various issues with
_download
they all ate, honestly π
πΈ AUTHOR πΈ
brian d foy, <bdfoy@cpan.org>
π COPYRIGHT π
Copyright (c) 2001-2021, brian d foy, All Rights Reserved.
You may redistribute this under the same terms as Perl itself.
okay that's the whole page, you're basically a CPAN girlie now π this was App::Cpan(3perl) β Perl Programmers Reference Guide, shipped with perl v5.44.0, dated 2026-10-17. mwah π go install something. bye bestie! π¦β¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms