blob: 0a80a18203e52e45feaf4dace981ef9f7274634b [file] [log] [blame]
Jeff Vander Stoep956d1432020-09-18 13:46:24 +02001'\" t
2.\" Title: cargo-package
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 2.0.10
5.\" Date: 2020-06-25
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-PACKAGE" "1" "2020-06-25" "\ \&" "\ \&"
11.ie \n(.g .ds Aq \(aq
12.el .ds Aq '
13.ss \n[.ss] 0
14.nh
15.ad l
16.de URL
17\fI\\$2\fP <\\$1>\\$3
18..
19.als MTO URL
20.if \n[.g] \{\
21. mso www.tmac
22. am URL
23. ad l
24. .
25. am MTO
26. ad l
27. .
28. LINKSTYLE blue R < >
29.\}
30.SH "NAME"
31cargo\-package \- Assemble the local package into a distributable tarball
32.SH "SYNOPSIS"
33.sp
34\fBcargo package [\fIOPTIONS\fP]\fP
35.SH "DESCRIPTION"
36.sp
37This command will create a distributable, compressed \fB.crate\fP file with the
38source code of the package in the current directory. The resulting file will
39be stored in the \fBtarget/package\fP directory. This performs the following
40steps:
41.sp
42.RS 4
43.ie n \{\
44\h'-04' 1.\h'+01'\c
45.\}
46.el \{\
47. sp -1
48. IP " 1." 4.2
49.\}
50Load and check the current workspace, performing some basic checks.
51.sp
52.RS 4
53.ie n \{\
54\h'-04'\(bu\h'+03'\c
55.\}
56.el \{\
57. sp -1
58. IP \(bu 2.3
59.\}
60Path dependencies are not allowed unless they have a version key. Cargo
61will ignore the path key for dependencies in published packages.
62\fBdev\-dependencies\fP do not have this restriction.
63.RE
64.RE
65.sp
66.RS 4
67.ie n \{\
68\h'-04' 2.\h'+01'\c
69.\}
70.el \{\
71. sp -1
72. IP " 2." 4.2
73.\}
74Create the compressed \fB.crate\fP file.
75.sp
76.RS 4
77.ie n \{\
78\h'-04'\(bu\h'+03'\c
79.\}
80.el \{\
81. sp -1
82. IP \(bu 2.3
83.\}
84The original \fBCargo.toml\fP file is rewritten and normalized.
85.RE
86.sp
87.RS 4
88.ie n \{\
89\h'-04'\(bu\h'+03'\c
90.\}
91.el \{\
92. sp -1
93. IP \(bu 2.3
94.\}
95\fB[patch]\fP, \fB[replace]\fP, and \fB[workspace]\fP sections are removed from the
96manifest.
97.RE
98.sp
99.RS 4
100.ie n \{\
101\h'-04'\(bu\h'+03'\c
102.\}
103.el \{\
104. sp -1
105. IP \(bu 2.3
106.\}
107\fBCargo.lock\fP is automatically included if the package contains an
108executable binary or example target. \fBcargo\-install\fP(1) will use the
109packaged lock file if the \fB\-\-locked\fP flag is used.
110.RE
111.sp
112.RS 4
113.ie n \{\
114\h'-04'\(bu\h'+03'\c
115.\}
116.el \{\
117. sp -1
118. IP \(bu 2.3
119.\}
120A \fB.cargo_vcs_info.json\fP file is included that contains information
121about the current VCS checkout hash if available (not included with
122\fB\-\-allow\-dirty\fP).
123.RE
124.RE
125.sp
126.RS 4
127.ie n \{\
128\h'-04' 3.\h'+01'\c
129.\}
130.el \{\
131. sp -1
132. IP " 3." 4.2
133.\}
134Extract the \fB.crate\fP file and build it to verify it can build.
135.sp
136.RS 4
137.ie n \{\
138\h'-04'\(bu\h'+03'\c
139.\}
140.el \{\
141. sp -1
142. IP \(bu 2.3
143.\}
144This will rebuild your package from scratch to ensure that it can be
145built from a pristine state. The \fB\-\-no\-verify\fP flag can be used to skip
146this step.
147.RE
148.RE
149.sp
150.RS 4
151.ie n \{\
152\h'-04' 4.\h'+01'\c
153.\}
154.el \{\
155. sp -1
156. IP " 4." 4.2
157.\}
158Check that build scripts did not modify any source files.
159.RE
160.sp
161The list of files included can be controlled with the \fBinclude\fP and \fBexclude\fP
162fields in the manifest.
163.sp
164See \c
165.URL "https://doc.rust\-lang.org/cargo/reference/publishing.html" "the reference" " "
166for more details about
167packaging and publishing.
168.SH "OPTIONS"
169.SS "Package Options"
170.sp
171\fB\-l\fP, \fB\-\-list\fP
172.RS 4
173Print files included in a package without making one.
174.RE
175.sp
176\fB\-\-no\-verify\fP
177.RS 4
178Don\(cqt verify the contents by building them.
179.RE
180.sp
181\fB\-\-no\-metadata\fP
182.RS 4
183Ignore warnings about a lack of human\-usable metadata (such as the
184description or the license).
185.RE
186.sp
187\fB\-\-allow\-dirty\fP
188.RS 4
189Allow working directories with uncommitted VCS changes to be packaged.
190.RE
191.SS "Compilation Options"
192.sp
193\fB\-\-target\fP \fITRIPLE\fP
194.RS 4
195Package for the given architecture. The default is the host
196architecture. The general format of the triple is
197\fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a
198list of supported targets.
199.sp
200This may also be specified with the \fBbuild.target\fP
201.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
202.sp
203Note that specifying this flag makes Cargo run in a different mode where the
204target artifacts are placed in a separate directory. See the
205.URL "https://doc.rust\-lang.org/cargo/guide/build\-cache.html" "build cache" " "
206documentation for more details.
207.RE
208.sp
209\fB\-\-target\-dir\fP \fIDIRECTORY\fP
210.RS 4
211Directory for all generated artifacts and intermediate files. May also be
212specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the
213\fBbuild.target\-dir\fP \c
214.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
215Defaults
216to \fBtarget\fP in the root of the workspace.
217.RE
218.SS "Feature Selection"
219.sp
220The feature flags allow you to control the enabled features for the "current"
221package. The "current" package is the package in the current directory, or the
222one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual
223workspace, then the default features are selected for all workspace members,
224or all features if \fB\-\-all\-features\fP is specified.
225.sp
226When no feature options are given, the \fBdefault\fP feature is activated for
227every selected package.
228.sp
229\fB\-\-features\fP \fIFEATURES\fP
230.RS 4
231Space or comma separated list of features to activate. These features only
232apply to the current directory\(cqs package. Features of direct dependencies
233may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. This flag may be
234specified multiple times, which enables all specified features.
235.RE
236.sp
237\fB\-\-all\-features\fP
238.RS 4
239Activate all available features of all selected packages.
240.RE
241.sp
242\fB\-\-no\-default\-features\fP
243.RS 4
244Do not activate the \fBdefault\fP feature of the current directory\(cqs
245package.
246.RE
247.SS "Manifest Options"
248.sp
249\fB\-\-manifest\-path\fP \fIPATH\fP
250.RS 4
251Path to the \fBCargo.toml\fP file. By default, Cargo searches for the
252\fBCargo.toml\fP file in the current directory or any parent directory.
253.RE
254.sp
255\fB\-\-frozen\fP, \fB\-\-locked\fP
256.RS 4
257Either of these flags requires that the \fBCargo.lock\fP file is
258up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
259exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
260attempting to access the network to determine if it is out\-of\-date.
261.sp
262These may be used in environments where you want to assert that the
263\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
264access.
265.RE
266.sp
267\fB\-\-offline\fP
268.RS 4
269Prevents Cargo from accessing the network for any reason. Without this
270flag, Cargo will stop with an error if it needs to access the network and
271the network is not available. With this flag, Cargo will attempt to
272proceed without the network if possible.
273.sp
274Beware that this may result in different dependency resolution than online
275mode. Cargo will restrict itself to crates that are downloaded locally, even
276if there might be a newer version as indicated in the local copy of the index.
277See the \fBcargo\-fetch\fP(1) command to download dependencies before going
278offline.
279.sp
280May also be specified with the \fBnet.offline\fP \c
281.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
282.RE
283.SS "Miscellaneous Options"
284.sp
285\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP
286.RS 4
287Number of parallel jobs to run. May also be specified with the
288\fBbuild.jobs\fP \c
289.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
290Defaults to
291the number of CPUs.
292.RE
293.SS "Display Options"
294.sp
295\fB\-v\fP, \fB\-\-verbose\fP
296.RS 4
297Use verbose output. May be specified twice for "very verbose" output which
298includes extra output such as dependency warnings and build script output.
299May also be specified with the \fBterm.verbose\fP
300.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
301.RE
302.sp
303\fB\-q\fP, \fB\-\-quiet\fP
304.RS 4
305No output printed to stdout.
306.RE
307.sp
308\fB\-\-color\fP \fIWHEN\fP
309.RS 4
310Control when colored output is used. Valid values:
311.sp
312.RS 4
313.ie n \{\
314\h'-04'\(bu\h'+03'\c
315.\}
316.el \{\
317. sp -1
318. IP \(bu 2.3
319.\}
320\fBauto\fP (default): Automatically detect if color support is available on the
321terminal.
322.RE
323.sp
324.RS 4
325.ie n \{\
326\h'-04'\(bu\h'+03'\c
327.\}
328.el \{\
329. sp -1
330. IP \(bu 2.3
331.\}
332\fBalways\fP: Always display colors.
333.RE
334.sp
335.RS 4
336.ie n \{\
337\h'-04'\(bu\h'+03'\c
338.\}
339.el \{\
340. sp -1
341. IP \(bu 2.3
342.\}
343\fBnever\fP: Never display colors.
344.RE
345.sp
346May also be specified with the \fBterm.color\fP
347.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
348.RE
349.SS "Common Options"
350.sp
351\fB+TOOLCHAIN\fP
352.RS 4
353If Cargo has been installed with rustup, and the first argument to \fBcargo\fP
354begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such
355as \fB+stable\fP or \fB+nightly\fP).
356See the \c
357.URL "https://github.com/rust\-lang/rustup/" "rustup documentation"
358for more information about how toolchain overrides work.
359.RE
360.sp
361\fB\-h\fP, \fB\-\-help\fP
362.RS 4
363Prints help information.
364.RE
365.sp
366\fB\-Z\fP \fIFLAG\fP...
367.RS 4
368Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
369details.
370.RE
371.SH "ENVIRONMENT"
372.sp
373See \c
374.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
375for
376details on environment variables that Cargo reads.
377.SH "EXIT STATUS"
378.sp
3790
380.RS 4
381Cargo succeeded.
382.RE
383.sp
384101
385.RS 4
386Cargo failed to complete.
387.RE
388.SH "EXAMPLES"
389.sp
390.RS 4
391.ie n \{\
392\h'-04' 1.\h'+01'\c
393.\}
394.el \{\
395. sp -1
396. IP " 1." 4.2
397.\}
398Create a compressed \fB.crate\fP file of the current package:
399.sp
400.if n .RS 4
401.nf
402cargo package
403.fi
404.if n .RE
405.RE
406.SH "SEE ALSO"
407.sp
408\fBcargo\fP(1), \fBcargo\-publish\fP(1)