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. Note that the server will perform
25           additional checks on the crate.
26
27       This command requires you to be authenticated with either the --token
28       option or using cargo-login(1).
29
30       See the reference
31       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
32       details about packaging and publishing.
33

OPTIONS

35   Publish Options
36       --dry-run
37           Perform all checks without uploading.
38
39       --token token
40           API token to use when authenticating. This overrides the token
41           stored in the credentials file (which is created by
42           cargo-login(1)).
43
44           Cargo config
45           <https://doc.rust-lang.org/cargo/reference/config.html> environment
46           variables can be used to override the tokens stored in the
47           credentials file. The token for crates.io may be specified with the
48           CARGO_REGISTRY_TOKEN environment variable. Tokens for other
49           registries may be specified with environment variables of the form
50           CARGO_REGISTRIES_NAME_TOKEN where NAME is the name of the registry
51           in all capital letters.
52
53       --no-verify
54           Don't verify the contents by building them.
55
56       --allow-dirty
57           Allow working directories with uncommitted VCS changes to be
58           packaged.
59
60       --index index
61           The URL of the registry index to use.
62
63       --registry registry
64           Name of the registry to publish to. Registry names are defined in
65           Cargo config files
66           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
67           specified, and there is a package.publish
68           <https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field>
69           field in Cargo.toml with a single registry, then it will publish to
70           that registry. Otherwise it will use the default registry, which is
71           defined by the registry.default
72           <https://doc.rust-lang.org/cargo/reference/config.html#registrydefault>
73           config key which defaults to crates-io.
74
75   Compilation Options
76       --target triple
77           Publish for the given architecture. The default is the host
78           architecture. The general format of the triple is
79           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
80           a list of supported targets.
81
82           This may also be specified with the build.target config value
83           <https://doc.rust-lang.org/cargo/reference/config.html>.
84
85           Note that specifying this flag makes Cargo run in a different mode
86           where the target artifacts are placed in a separate directory. See
87           the build cache
88           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
89           documentation for more details.
90
91       --target-dir directory
92           Directory for all generated artifacts and intermediate files. May
93           also be specified with the CARGO_TARGET_DIR environment variable,
94           or the build.target-dir config value
95           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
96           to target in the root of the workspace.
97
98   Feature Selection
99       The feature flags allow you to control which features are enabled. When
100       no feature options are given, the default feature is activated for
101       every selected package.
102
103       See the features documentation
104       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
105       for more details.
106
107       --features features
108           Space or comma separated list of features to activate. Features of
109           workspace members may be enabled with package-name/feature-name
110           syntax. This flag may be specified multiple times, which enables
111           all specified features.
112
113       --all-features
114           Activate all available features of all selected packages.
115
116       --no-default-features
117           Do not activate the default feature of the selected packages.
118
119   Manifest Options
120       --manifest-path path
121           Path to the Cargo.toml file. By default, Cargo searches for the
122           Cargo.toml file in the current directory or any parent directory.
123
124       --frozen, --locked
125           Either of these flags requires that the Cargo.lock file is
126           up-to-date. If the lock file is missing, or it needs to be updated,
127           Cargo will exit with an error. The --frozen flag also prevents
128           Cargo from attempting to access the network to determine if it is
129           out-of-date.
130
131           These may be used in environments where you want to assert that the
132           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
133           network access.
134
135       --offline
136           Prevents Cargo from accessing the network for any reason. Without
137           this flag, Cargo will stop with an error if it needs to access the
138           network and the network is not available. With this flag, Cargo
139           will attempt to proceed without the network if possible.
140
141           Beware that this may result in different dependency resolution than
142           online mode. Cargo will restrict itself to crates that are
143           downloaded locally, even if there might be a newer version as
144           indicated in the local copy of the index. See the cargo-fetch(1)
145           command to download dependencies before going offline.
146
147           May also be specified with the net.offline config value
148           <https://doc.rust-lang.org/cargo/reference/config.html>.
149
150   Miscellaneous Options
151       -j N, --jobs N
152           Number of parallel jobs to run. May also be specified with the
153           build.jobs config value
154           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
155           to the number of CPUs.
156
157   Display Options
158       -v, --verbose
159           Use verbose output. May be specified twice for "very verbose"
160           output which includes extra output such as dependency warnings and
161           build script output. May also be specified with the term.verbose
162           config value
163           <https://doc.rust-lang.org/cargo/reference/config.html>.
164
165       -q, --quiet
166           No output printed to stdout.
167
168       --color when
169           Control when colored output is used. Valid values:
170
171auto (default): Automatically detect if color support is
172               available on the terminal.
173
174always: Always display colors.
175
176never: Never display colors.
177
178           May also be specified with the term.color config value
179           <https://doc.rust-lang.org/cargo/reference/config.html>.
180
181   Common Options
182       +toolchain
183           If Cargo has been installed with rustup, and the first argument to
184           cargo begins with +, it will be interpreted as a rustup toolchain
185           name (such as +stable or +nightly). See the rustup documentation
186           <https://rust-lang.github.io/rustup/overrides.html> for more
187           information about how toolchain overrides work.
188
189       -h, --help
190           Prints help information.
191
192       -Z flag
193           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
194           details.
195

ENVIRONMENT

197       See the reference
198       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
199       for details on environment variables that Cargo reads.
200

EXIT STATUS

2020: Cargo succeeded.
203
204101: Cargo failed to complete.
205

EXAMPLES

207        1. Publish the current package:
208
209               cargo publish
210

SEE ALSO

212       cargo(1), cargo-package(1), cargo-login(1)
213
214
215
216                                                              CARGO-PUBLISH(1)
Impressum