1CARGO-PACKAGE(1)            General Commands Manual           CARGO-PACKAGE(1)
2
3
4

NAME

6       cargo-package — Assemble the local package into a distributable tarball
7

SYNOPSIS

9       cargo package [options]
10

DESCRIPTION

12       This command will create a distributable, compressed .crate file with
13       the source code of the package in the current directory. The resulting
14       file will be stored in the target/package directory. This performs the
15       following steps:
16
17        1. Load and check the current workspace, performing some basic checks.
18
19           •  Path dependencies are not allowed unless they have a version
20               key. Cargo will ignore the path key for dependencies in
21               published packages. dev-dependencies do not have this
22               restriction.
23
24        2. Create the compressed .crate file.
25
26           •  The original Cargo.toml file is rewritten and normalized.
27
28[patch], [replace], and [workspace] sections are removed from
29               the manifest.
30
31Cargo.lock is automatically included if the package contains an
32               executable binary or example target. cargo-install(1) will use
33               the packaged lock file if the --locked flag is used.
34
35           •  A .cargo_vcs_info.json file is included that contains
36               information about the current VCS checkout hash if available
37               (not included with --allow-dirty).
38
39        3. Extract the .crate file and build it to verify it can build.
40
41           •  This will rebuild your package from scratch to ensure that it
42               can be built from a pristine state. The --no-verify flag can be
43               used to skip this step.
44
45        4. Check that build scripts did not modify any source files.
46
47       The list of files included can be controlled with the include and
48       exclude fields in the manifest.
49
50       See the reference
51       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
52       details about packaging and publishing.
53
54   .cargo_vcs_info.json format
55       Will generate a .cargo_vcs_info.json in the following format
56
57           {
58            "git": {
59              "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302"
60            },
61            "path_in_vcs": ""
62           }
63
64       path_in_vcs will be set to a repo-relative path for packages in
65       subdirectories of the version control repository.
66

OPTIONS

68   Package Options
69       -l, --list
70           Print files included in a package without making one.
71
72       --no-verify
73           Don’t verify the contents by building them.
74
75       --no-metadata
76           Ignore warnings about a lack of human-usable metadata (such as the
77           description or the license).
78
79       --allow-dirty
80           Allow working directories with uncommitted VCS changes to be
81           packaged.
82
83   Package Selection
84       By default, when no package selection options are given, the packages
85       selected depend on the selected manifest file (based on the current
86       working directory if --manifest-path is not given). If the manifest is
87       the root of a workspace then the workspaces default members are
88       selected, otherwise only the package defined by the manifest will be
89       selected.
90
91       The default members of a workspace can be set explicitly with the
92       workspace.default-members key in the root manifest. If this is not set,
93       a virtual workspace will include all workspace members (equivalent to
94       passing --workspace), and a non-virtual workspace will include only the
95       root crate itself.
96
97       -p spec…, --package spec…
98           Package only the specified packages. See cargo-pkgid(1) for the
99           SPEC format. This flag may be specified multiple times and supports
100           common Unix glob patterns like *, ? and []. However, to avoid your
101           shell accidentally expanding glob patterns before Cargo handles
102           them, you must use single quotes or double quotes around each
103           pattern.
104
105       --workspace
106           Package all members in the workspace.
107
108       --exclude SPEC…
109           Exclude the specified packages. Must be used in conjunction with
110           the --workspace flag. This flag may be specified multiple times and
111           supports common Unix glob patterns like *, ? and []. However, to
112           avoid your shell accidentally expanding glob patterns before Cargo
113           handles them, you must use single quotes or double quotes around
114           each pattern.
115
116   Compilation Options
117       --target triple
118           Package for the given architecture. The default is the host
119           architecture. The general format of the triple is
120           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
121           a list of supported targets. This flag may be specified multiple
122           times.
123
124           This may also be specified with the build.target config value
125           <https://doc.rust-lang.org/cargo/reference/config.html>.
126
127           Note that specifying this flag makes Cargo run in a different mode
128           where the target artifacts are placed in a separate directory. See
129           the build cache
130           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
131           documentation for more details.
132
133       --target-dir directory
134           Directory for all generated artifacts and intermediate files. May
135           also be specified with the CARGO_TARGET_DIR environment variable,
136           or the build.target-dir config value
137           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
138           to target in the root of the workspace.
139
140   Feature Selection
141       The feature flags allow you to control which features are enabled. When
142       no feature options are given, the default feature is activated for
143       every selected package.
144
145       See the features documentation
146       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
147       for more details.
148
149       -F features, --features features
150           Space or comma separated list of features to activate. Features of
151           workspace members may be enabled with package-name/feature-name
152           syntax. This flag may be specified multiple times, which enables
153           all specified features.
154
155       --all-features
156           Activate all available features of all selected packages.
157
158       --no-default-features
159           Do not activate the default feature of the selected packages.
160
161   Manifest Options
162       --manifest-path path
163           Path to the Cargo.toml file. By default, Cargo searches for the
164           Cargo.toml file in the current directory or any parent directory.
165
166       --frozen, --locked
167           Either of these flags requires that the Cargo.lock file is
168           up-to-date. If the lock file is missing, or it needs to be updated,
169           Cargo will exit with an error. The --frozen flag also prevents
170           Cargo from attempting to access the network to determine if it is
171           out-of-date.
172
173           These may be used in environments where you want to assert that the
174           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
175           network access.
176
177       --offline
178           Prevents Cargo from accessing the network for any reason. Without
179           this flag, Cargo will stop with an error if it needs to access the
180           network and the network is not available. With this flag, Cargo
181           will attempt to proceed without the network if possible.
182
183           Beware that this may result in different dependency resolution than
184           online mode. Cargo will restrict itself to crates that are
185           downloaded locally, even if there might be a newer version as
186           indicated in the local copy of the index. See the cargo-fetch(1)
187           command to download dependencies before going offline.
188
189           May also be specified with the net.offline config value
190           <https://doc.rust-lang.org/cargo/reference/config.html>.
191
192   Miscellaneous Options
193       -j N, --jobs N
194           Number of parallel jobs to run. May also be specified with the
195           build.jobs config value
196           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
197           to the number of logical CPUs. If negative, it sets the maximum
198           number of parallel jobs to the number of logical CPUs plus provided
199           value. If a string default is provided, it sets the value back to
200           defaults. Should not be 0.
201
202       --keep-going
203           Build as many crates in the dependency graph as possible, rather
204           than aborting the build on the first one that fails to build.
205
206           For example if the current package depends on dependencies fails
207           and works, one of which fails to build, cargo package -j1 may or
208           may not build the one that succeeds (depending on which one of the
209           two builds Cargo picked to run first), whereas cargo package -j1
210           --keep-going would definitely run both builds, even if the one run
211           first fails.
212
213   Display Options
214       -v, --verbose
215           Use verbose output. May be specified twice for “very verbose”
216           output which includes extra output such as dependency warnings and
217           build script output. May also be specified with the term.verbose
218           config value
219           <https://doc.rust-lang.org/cargo/reference/config.html>.
220
221       -q, --quiet
222           Do not print cargo log messages. May also be specified with the
223           term.quiet config value
224           <https://doc.rust-lang.org/cargo/reference/config.html>.
225
226       --color when
227           Control when colored output is used. Valid values:
228
229auto (default): Automatically detect if color support is
230               available on the terminal.
231
232always: Always display colors.
233
234never: Never display colors.
235
236           May also be specified with the term.color config value
237           <https://doc.rust-lang.org/cargo/reference/config.html>.
238
239   Common Options
240       +toolchain
241           If Cargo has been installed with rustup, and the first argument to
242           cargo begins with +, it will be interpreted as a rustup toolchain
243           name (such as +stable or +nightly). See the rustup documentation
244           <https://rust-lang.github.io/rustup/overrides.html> for more
245           information about how toolchain overrides work.
246
247       --config KEY=VALUE or PATH
248           Overrides a Cargo configuration value. The argument should be in
249           TOML syntax of KEY=VALUE, or provided as a path to an extra
250           configuration file. This flag may be specified multiple times. See
251           the command-line overrides section
252           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
253           for more information.
254
255       -C PATH
256           Changes the current working directory before executing any
257           specified operations. This affects things like where cargo looks by
258           default for the project manifest (Cargo.toml), as well as the
259           directories searched for discovering .cargo/config.toml, for
260           example. This option must appear before the command name, for
261           example cargo -C path/to/my-project build.
262
263           This option is only available on the nightly channel
264           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
265           requires the -Z unstable-options flag to enable (see #10098
266           <https://github.com/rust-lang/cargo/issues/10098>).
267
268       -h, --help
269           Prints help information.
270
271       -Z flag
272           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
273           details.
274

ENVIRONMENT

276       See the reference
277       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
278       for details on environment variables that Cargo reads.
279

EXIT STATUS

2810: Cargo succeeded.
282
283101: Cargo failed to complete.
284

EXAMPLES

286        1. Create a compressed .crate file of the current package:
287
288               cargo package
289

SEE ALSO

291       cargo(1), cargo-publish(1)
292
293
294
295                                                              CARGO-PACKAGE(1)
Impressum