1App::cpm::Tutorial(3pm)User Contributed Perl DocumentatioAnpp::cpm::Tutorial(3pm)
2
3
4
6 App::cpm::Tutorial - How to use cpm
7
9 $ cpm install Module
10
12 cpm is yet another CPAN client (like cpan, cpanp, and cpanm), which is
13 fast!
14
15 How to install cpm
16 From CPAN:
17
18 $ curl -fsSL https://raw.githubusercontent.com/skaji/cpm/main/cpm | perl - install -g App::cpm
19
20 Or, download a self-contained cpm:
21
22 $ curl -fsSL https://raw.githubusercontent.com/skaji/cpm/main/cpm > cpm
23 $ chmod +x cpm
24 $ ./cpm --version
25
26 First step
27 $ cpm install Plack
28
29 This command installs Plack into "./local", and you can use it by
30
31 $ perl -I$PWD/local/lib/perl5 -MPlack -E 'say Plack->VERSION'
32
33 If you want to install modules into current INC instead of "./local",
34 then use "--global/-g" option.
35
36 $ cpm install --global Plack
37
38 By default, cpm outputs only "DONE install Module" things. If you want
39 more verbose messages, use "--verbose/-v" option.
40
41 $ cpm install --verbose Plack
42
43 Second step
44 cpm can handle version range notation like cpanm. Let's see some
45 examples.
46
47 $ cpm install Plack~'> 1.000, <= 2.000'
48 $ cpm install Plack~'== 1.0030'
49 $ cpm install Plack@1.0030 # this is an alias of ~'== 1.0030'
50
51 cpm can install dev releases (TRIAL releases).
52
53 $ cpm install Moose@dev
54
55 # if you prefer dev releases for not only Moose,
56 # but also its dependencies, then use global --dev option
57 $ cpm install --dev Moose
58
59 And cpm can install modules from git repositories directly.
60
61 $ cpm install https://github.com/skaji/Carl.git
62
63 cpanfile and dist/url/mirror/git syntax
64 If you omit arguments, and there exists "cpanfile" in the current
65 directory, then cpm loads modules from cpanfile, and install them
66
67 $ cat cpanfile
68 requires 'Moose', '2.000';
69 requires 'Plack', '> 1.000, <= 2.000';
70 $ cpm install
71
72 If you have "cpanfile.snapshot", then cpm tries to resolve distribution
73 names from it
74
75 $ cpm install -v
76 30186 DONE resolve (0.001sec) Plack -> Plack-1.0030 (from Snapshot)
77 ...
78
79 cpm supports dist/url/mirror syntax in cpanfile just like cpanminus:
80
81 requires 'Path::Class', 0.26,
82 dist => "KWILLIAMS/Path-Class-0.26.tar.gz";
83
84 # use dist + mirror
85 requires 'Cookie::Baker',
86 dist => "KAZEBURO/Cookie-Baker-0.08.tar.gz",
87 mirror => "http://cpan.cpantesters.org/";
88
89 # use the full URL
90 requires 'Try::Tiny', 0.28,
91 url => "http://backpan.perl.org/authors/id/E/ET/ETHER/Try-Tiny-0.28.tar.gz";
92
93 cpm also supports git syntax in cpanfile:
94
95 requires 'Carl', git => 'https://github.com/skaji/Carl.git';
96 requires 'App::cpm', git => 'https://login:password@github.com/skaji/cpm.git';
97 requires 'Perl::PrereqDistributionGatherer',
98 git => 'https://github.com/skaji/Perl-PrereqDistributionGatherer',
99 ref => '3850305'; # ref can be revision/branch/tag
100
101 Please note that to support git syntax in cpanfile wholly, there are
102 several TODOs.
103
104 Darkpan integration
105 There are CPAN modules that create darkpans (minicpan, CPAN mirror)
106 such as CPAN::Mini, OrePAN2, Pinto.
107
108 Such darkpans store distribution tarballs in
109
110 DARKPAN/authors/id/A/AU/AUTHOR/Module-0.01.tar.gz
111
112 and create the de facto standard index file "02packages.details.txt.gz"
113 in
114
115 DARKPAN/modules/02packages.details.txt.gz
116
117 If you want to use cpm against such darkpans, change the cpm resolver
118 by "--resolver/-r" option:
119
120 $ cpm install --resolver 02packages,http://example.com/darkpan Module
121 $ cpm install --resolver 02packages,file::///path/to/darkpan Module
122
123 Sometimes, your darkpan is not whole CPAN mirror, but partial, so some
124 modules are missing in it. Then append "--resolver metadb" option to
125 fall back to normal MetaDB resolver:
126
127 $ cpm install \
128 --resolver 02packages,http://example.com/darkpan \
129 --resolver metadb \
130 Module
131
132 If you host your own darkmetadb for your own darkpan, you can use it
133 too. Then append "--resolver metadb" option to fall back to normal
134 MetaDB resolver:
135
136 $ cpm install \
137 --resolver metadb,http://example.com/darkmetadb,http://example.com/darkpan \
138 --resolver metadb \
139 Module
140
141
142
143perl v5.34.1 2022-04-27 App::cpm::Tutorial(3pm)