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. Should not be 0.
200
201       --keep-going
202           Build as many crates in the dependency graph as possible, rather
203           than aborting the build on the first one that fails to build.
204           Unstable, requires -Zunstable-options.
205
206   Display Options
207       -v, --verbose
208           Use verbose output. May be specified twice for "very verbose"
209           output which includes extra output such as dependency warnings and
210           build script output. May also be specified with the term.verbose
211           config value
212           <https://doc.rust-lang.org/cargo/reference/config.html>.
213
214       -q, --quiet
215           Do not print cargo log messages. May also be specified with the
216           term.quiet config value
217           <https://doc.rust-lang.org/cargo/reference/config.html>.
218
219       --color when
220           Control when colored output is used. Valid values:
221
222auto (default): Automatically detect if color support is
223               available on the terminal.
224
225always: Always display colors.
226
227never: Never display colors.
228
229           May also be specified with the term.color config value
230           <https://doc.rust-lang.org/cargo/reference/config.html>.
231
232   Common Options
233       +toolchain
234           If Cargo has been installed with rustup, and the first argument to
235           cargo begins with +, it will be interpreted as a rustup toolchain
236           name (such as +stable or +nightly). See the rustup documentation
237           <https://rust-lang.github.io/rustup/overrides.html> for more
238           information about how toolchain overrides work.
239
240       --config KEY=VALUE or PATH
241           Overrides a Cargo configuration value. The argument should be in
242           TOML syntax of KEY=VALUE, or provided as a path to an extra
243           configuration file. This flag may be specified multiple times. See
244           the command-line overrides section
245           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
246           for more information.
247
248       -h, --help
249           Prints help information.
250
251       -Z flag
252           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
253           details.
254

ENVIRONMENT

256       See the reference
257       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
258       for details on environment variables that Cargo reads.
259

EXIT STATUS

2610: Cargo succeeded.
262
263101: Cargo failed to complete.
264

EXAMPLES

266        1. Create a compressed .crate file of the current package:
267
268               cargo package
269

SEE ALSO

271       cargo(1), cargo-publish(1)
272
273
274
275                                                              CARGO-PACKAGE(1)
Impressum