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

NAME

6       cargo-publish — Upload a package to the registry
7

SYNOPSIS

9       cargo publish [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 and upload it
14       to a registry. The default registry is <https://crates.io>. This
15       performs the following steps:
16
17        1. Performs a few checks, including:
18
19           •  Checks the package.publish key in the manifest for restrictions
20               on which registries you are allowed to publish to.
21
22        2. Create a .crate file by following the steps in cargo-package(1).
23
24        3. Upload the crate to the registry. The server will perform
25           additional checks on the crate.
26
27        4. The client will poll waiting for the package to appear in the
28           index, and may timeout. In that case, you will need to check for
29           completion manually. This timeout does not affect the upload.
30
31       This command requires you to be authenticated with either the --token
32       option or using cargo-login(1).
33
34       See the reference
35       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
36       details about packaging and publishing.
37

OPTIONS

39   Publish Options
40       --dry-run
41           Perform all checks without uploading.
42
43       --token token
44           API token to use when authenticating. This overrides the token
45           stored in the credentials file (which is created by
46           cargo-login(1)).
47
48           Cargo config
49           <https://doc.rust-lang.org/cargo/reference/config.html> environment
50           variables can be used to override the tokens stored in the
51           credentials file. The token for crates.io may be specified with the
52           CARGO_REGISTRY_TOKEN environment variable. Tokens for other
53           registries may be specified with environment variables of the form
54           CARGO_REGISTRIES_NAME_TOKEN where NAME is the name of the registry
55           in all capital letters.
56
57       --no-verify
58           Don’t verify the contents by building them.
59
60       --allow-dirty
61           Allow working directories with uncommitted VCS changes to be
62           packaged.
63
64       --index index
65           The URL of the registry index to use.
66
67       --registry registry
68           Name of the registry to publish to. Registry names are defined in
69           Cargo config files
70           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
71           specified, and there is a package.publish
72           <https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field>
73           field in Cargo.toml with a single registry, then it will publish to
74           that registry. Otherwise it will use the default registry, which is
75           defined by the registry.default
76           <https://doc.rust-lang.org/cargo/reference/config.html#registrydefault>
77           config key which defaults to crates-io.
78
79   Package Selection
80       By default, the package in the current working directory is selected.
81       The -p flag can be used to choose a different package in a workspace.
82
83       -p spec, --package spec
84           The package to publish. See cargo-pkgid(1) for the SPEC format.
85
86   Compilation Options
87       --target triple
88           Publish for the given architecture. The default is the host
89           architecture. The general format of the triple is
90           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
91           a list of supported targets. This flag may be specified multiple
92           times.
93
94           This may also be specified with the build.target config value
95           <https://doc.rust-lang.org/cargo/reference/config.html>.
96
97           Note that specifying this flag makes Cargo run in a different mode
98           where the target artifacts are placed in a separate directory. See
99           the build cache
100           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
101           documentation for more details.
102
103       --target-dir directory
104           Directory for all generated artifacts and intermediate files. May
105           also be specified with the CARGO_TARGET_DIR environment variable,
106           or the build.target-dir config value
107           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
108           to target in the root of the workspace.
109
110   Feature Selection
111       The feature flags allow you to control which features are enabled. When
112       no feature options are given, the default feature is activated for
113       every selected package.
114
115       See the features documentation
116       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
117       for more details.
118
119       -F features, --features features
120           Space or comma separated list of features to activate. Features of
121           workspace members may be enabled with package-name/feature-name
122           syntax. This flag may be specified multiple times, which enables
123           all specified features.
124
125       --all-features
126           Activate all available features of all selected packages.
127
128       --no-default-features
129           Do not activate the default feature of the selected packages.
130
131   Manifest Options
132       --manifest-path path
133           Path to the Cargo.toml file. By default, Cargo searches for the
134           Cargo.toml file in the current directory or any parent directory.
135
136       --frozen, --locked
137           Either of these flags requires that the Cargo.lock file is
138           up-to-date. If the lock file is missing, or it needs to be updated,
139           Cargo will exit with an error. The --frozen flag also prevents
140           Cargo from attempting to access the network to determine if it is
141           out-of-date.
142
143           These may be used in environments where you want to assert that the
144           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
145           network access.
146
147       --offline
148           Prevents Cargo from accessing the network for any reason. Without
149           this flag, Cargo will stop with an error if it needs to access the
150           network and the network is not available. With this flag, Cargo
151           will attempt to proceed without the network if possible.
152
153           Beware that this may result in different dependency resolution than
154           online mode. Cargo will restrict itself to crates that are
155           downloaded locally, even if there might be a newer version as
156           indicated in the local copy of the index. See the cargo-fetch(1)
157           command to download dependencies before going offline.
158
159           May also be specified with the net.offline config value
160           <https://doc.rust-lang.org/cargo/reference/config.html>.
161
162   Miscellaneous Options
163       -j N, --jobs N
164           Number of parallel jobs to run. May also be specified with the
165           build.jobs config value
166           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
167           to the number of logical CPUs. If negative, it sets the maximum
168           number of parallel jobs to the number of logical CPUs plus provided
169           value. If a string default is provided, it sets the value back to
170           defaults. Should not be 0.
171
172       --keep-going
173           Build as many crates in the dependency graph as possible, rather
174           than aborting the build on the first one that fails to build.
175
176           For example if the current package depends on dependencies fails
177           and works, one of which fails to build, cargo publish -j1 may or
178           may not build the one that succeeds (depending on which one of the
179           two builds Cargo picked to run first), whereas cargo publish -j1
180           --keep-going would definitely run both builds, even if the one run
181           first fails.
182
183   Display Options
184       -v, --verbose
185           Use verbose output. May be specified twice for “very verbose”
186           output which includes extra output such as dependency warnings and
187           build script output. May also be specified with the term.verbose
188           config value
189           <https://doc.rust-lang.org/cargo/reference/config.html>.
190
191       -q, --quiet
192           Do not print cargo log messages. May also be specified with the
193           term.quiet config value
194           <https://doc.rust-lang.org/cargo/reference/config.html>.
195
196       --color when
197           Control when colored output is used. Valid values:
198
199auto (default): Automatically detect if color support is
200               available on the terminal.
201
202always: Always display colors.
203
204never: Never display colors.
205
206           May also be specified with the term.color config value
207           <https://doc.rust-lang.org/cargo/reference/config.html>.
208
209   Common Options
210       +toolchain
211           If Cargo has been installed with rustup, and the first argument to
212           cargo begins with +, it will be interpreted as a rustup toolchain
213           name (such as +stable or +nightly). See the rustup documentation
214           <https://rust-lang.github.io/rustup/overrides.html> for more
215           information about how toolchain overrides work.
216
217       --config KEY=VALUE or PATH
218           Overrides a Cargo configuration value. The argument should be in
219           TOML syntax of KEY=VALUE, or provided as a path to an extra
220           configuration file. This flag may be specified multiple times. See
221           the command-line overrides section
222           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
223           for more information.
224
225       -C PATH
226           Changes the current working directory before executing any
227           specified operations. This affects things like where cargo looks by
228           default for the project manifest (Cargo.toml), as well as the
229           directories searched for discovering .cargo/config.toml, for
230           example. This option must appear before the command name, for
231           example cargo -C path/to/my-project build.
232
233           This option is only available on the nightly channel
234           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
235           requires the -Z unstable-options flag to enable (see #10098
236           <https://github.com/rust-lang/cargo/issues/10098>).
237
238       -h, --help
239           Prints help information.
240
241       -Z flag
242           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
243           details.
244

ENVIRONMENT

246       See the reference
247       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
248       for details on environment variables that Cargo reads.
249

EXIT STATUS

2510: Cargo succeeded.
252
253101: Cargo failed to complete.
254

EXAMPLES

256        1. Publish the current package:
257
258               cargo publish
259

SEE ALSO

261       cargo(1), cargo-package(1), cargo-login(1)
262
263
264
265                                                              CARGO-PUBLISH(1)
Impressum