fork/cargo

git clone https://git.julia.blue/fork/cargo

Weihang Lo[beta-1.91] fix: use `host-tuple` for host target subsitution (#16032)ea2d97820

0.92.0
13.7 KiB320 linesraw
1CARGO-PUBLISH(1)
2
3NAME
4       cargo-publish — Upload a package to the registry
5
6SYNOPSIS
7       cargo publish [options]
8
9DESCRIPTION
10       This command will create a distributable, compressed .crate file with
11       the source code of the package in the current directory and upload it to
12       a registry. The default registry is <https://crates.io>. This performs
13       the following steps:
14
15       1. Performs a few checks, including:
16          o  Checks the package.publish key in the manifest for restrictions on
17             which registries you are allowed to publish to.
18
19       2. Create a .crate file by following the steps in cargo-package(1).
20
21       3. Upload the crate to the registry. The server will perform additional
22          checks on the crate.
23
24       4. The client will poll waiting for the package to appear in the index,
25          and may timeout. In that case, you will need to check for completion
26          manually. This timeout does not affect the upload.
27
28       This command requires you to be authenticated with either the --token
29       option or using cargo-login(1).
30
31       See the reference
32       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
33       details about packaging and publishing.
34
35OPTIONS
36   Publish Options
37       --dry-run
38           Perform all checks without uploading.
39
40       --token token
41           API token to use when authenticating. This overrides the token
42           stored in the credentials file (which is created by cargo-login(1)).
43
44           Cargo config <https://doc.rust-lang.org/cargo/reference/config.html>
45           environment variables can be used to override the tokens stored in
46           the credentials file. The token for crates.io may be specified with
47           the CARGO_REGISTRY_TOKEN environment variable. Tokens for other
48           registries may be specified with environment variables of the form
49           CARGO_REGISTRIES_NAME_TOKEN where NAME is the name of the registry
50           in all capital letters.
51
52       --no-verify
53           Don’t verify the contents by building them.
54
55       --allow-dirty
56           Allow working directories with uncommitted VCS changes to be
57           packaged.
58
59       --index index
60           The URL of the registry index to use.
61
62       --registry registry
63           Name of the registry to publish to. Registry names are defined in
64           Cargo config files
65           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
66           specified, and there is a package.publish
67           <https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field>
68           field in Cargo.toml with a single registry, then it will publish to
69           that registry. Otherwise it will use the default registry, which is
70           defined by the registry.default
71           <https://doc.rust-lang.org/cargo/reference/config.html#registrydefault>
72           config key which defaults to crates-io.
73
74   Package Selection
75       By default, when no package selection options are given, the packages
76       selected depend on the selected manifest file (based on the current
77       working directory if --manifest-path is not given). If the manifest is
78       the root of a workspace then the workspaces default members are
79       selected, otherwise only the package defined by the manifest will be
80       selected.
81
82       The default members of a workspace can be set explicitly with the
83       workspace.default-members key in the root manifest. If this is not set,
84       a virtual workspace will include all workspace members (equivalent to
85       passing --workspace), and a non-virtual workspace will include only the
86       root crate itself.
87
88       -p spec…, --package spec…
89           Publish only the specified packages. See cargo-pkgid(1) for the SPEC
90           format. This flag may be specified multiple times and supports
91           common Unix glob patterns like *, ? and []. However, to avoid your
92           shell accidentally expanding glob patterns before Cargo handles
93           them, you must use single quotes or double quotes around each
94           pattern.
95
96       --workspace
97           Publish all members in the workspace.
98
99       --all
100           Deprecated alias for --workspace.
101
102       --exclude SPEC…
103           Exclude the specified packages. Must be used in conjunction with the
104           --workspace flag. This flag may be specified multiple times and
105           supports common Unix glob patterns like *, ? and []. However, to
106           avoid your shell accidentally expanding glob patterns before Cargo
107           handles them, you must use single quotes or double quotes around
108           each pattern.
109
110   Compilation Options
111       --target triple
112           Publish for the specified target architecture. Flag may be specified
113           multiple times. The default is the host architecture. The general
114           format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.
115
116           Possible values:
117
118           o  Any supported target in rustc --print target-list.
119
120           o  "host-tuple", which will internally be substituted by the
121              host’s target. This can be particularly useful if you’re
122              cross-compiling some crates, and don’t want to specify your
123              host’s machine as a target (for instance, an xtask in a shared
124              project that may be worked on by many hosts).
125
126           o  A path to a custom target specification. See Custom Target Lookup
127              Path
128              <https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
129              for more information.
130
131           This may also be specified with the build.target config value
132           <https://doc.rust-lang.org/cargo/reference/config.html>.
133
134           Note that specifying this flag makes Cargo run in a different mode
135           where the target artifacts are placed in a separate directory. See
136           the build cache
137           <https://doc.rust-lang.org/cargo/reference/build-cache.html>
138           documentation for more details.
139
140       --target-dir directory
141           Directory for all generated artifacts and intermediate files. May
142           also be specified with the CARGO_TARGET_DIR environment variable, or
143           the build.target-dir config value
144           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
145           target in the root of the workspace.
146
147   Feature Selection
148       The feature flags allow you to control which features are enabled. When
149       no feature options are given, the default feature is activated for every
150       selected package.
151
152       See the features documentation
153       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
154       for more details.
155
156       -F features, --features features
157           Space or comma separated list of features to activate. Features of
158           workspace members may be enabled with package-name/feature-name
159           syntax. This flag may be specified multiple times, which enables all
160           specified features.
161
162       --all-features
163           Activate all available features of all selected packages.
164
165       --no-default-features
166           Do not activate the default feature of the selected packages.
167
168   Manifest Options
169       --manifest-path path
170           Path to the Cargo.toml file. By default, Cargo searches for the
171           Cargo.toml file in the current directory or any parent directory.
172
173       --locked
174           Asserts that the exact same dependencies and versions are used as
175           when the existing Cargo.lock file was originally generated. Cargo
176           will exit with an error when either of the following scenarios
177           arises:
178
179           o  The lock file is missing.
180
181           o  Cargo attempted to change the lock file due to a different
182              dependency resolution.
183
184           It may be used in environments where deterministic builds are
185           desired, such as in CI pipelines.
186
187       --offline
188           Prevents Cargo from accessing the network for any reason. Without
189           this flag, Cargo will stop with an error if it needs to access the
190           network and the network is not available. With this flag, Cargo will
191           attempt to proceed without the network if possible.
192
193           Beware that this may result in different dependency resolution than
194           online mode. Cargo will restrict itself to crates that are
195           downloaded locally, even if there might be a newer version as
196           indicated in the local copy of the index. See the cargo-fetch(1)
197           command to download dependencies before going offline.
198
199           May also be specified with the net.offline config value
200           <https://doc.rust-lang.org/cargo/reference/config.html>.
201
202       --frozen
203           Equivalent to specifying both --locked and --offline.
204
205       --lockfile-path PATH
206           Changes the path of the lockfile from the default
207           (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock
208           (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that
209           providing --lockfile-path will ignore existing lockfile at the
210           default path, and instead will either use the lockfile from PATH, or
211           write a new lockfile into the provided PATH if it doesn’t exist.
212           This flag can be used to run most commands in read-only directories,
213           writing lockfile into the provided PATH.
214
215           This option is only available on the nightly channel
216           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
217           requires the -Z unstable-options flag to enable (see #14421
218           <https://github.com/rust-lang/cargo/issues/14421>).
219
220   Miscellaneous Options
221       -j N, --jobs N
222           Number of parallel jobs to run. May also be specified with the
223           build.jobs config value
224           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
225           the number of logical CPUs. If negative, it sets the maximum number
226           of parallel jobs to the number of logical CPUs plus provided value.
227           If a string default is provided, it sets the value back to defaults.
228           Should not be 0.
229
230       --keep-going
231           Build as many crates in the dependency graph as possible, rather
232           than aborting the build on the first one that fails to build.
233
234           For example if the current package depends on dependencies fails and
235           works, one of which fails to build, cargo publish -j1 may or may not
236           build the one that succeeds (depending on which one of the two
237           builds Cargo picked to run first), whereas cargo publish -j1
238           --keep-going would definitely run both builds, even if the one run
239           first fails.
240
241   Display Options
242       -v, --verbose
243           Use verbose output. May be specified twice for “very verbose”
244           output which includes extra output such as dependency warnings and
245           build script output. May also be specified with the term.verbose
246           config value
247           <https://doc.rust-lang.org/cargo/reference/config.html>.
248
249       -q, --quiet
250           Do not print cargo log messages. May also be specified with the
251           term.quiet config value
252           <https://doc.rust-lang.org/cargo/reference/config.html>.
253
254       --color when
255           Control when colored output is used. Valid values:
256
257           o  auto (default): Automatically detect if color support is
258              available on the terminal.
259
260           o  always: Always display colors.
261
262           o  never: Never display colors.
263
264           May also be specified with the term.color config value
265           <https://doc.rust-lang.org/cargo/reference/config.html>.
266
267   Common Options
268       +toolchain
269           If Cargo has been installed with rustup, and the first argument to
270           cargo begins with +, it will be interpreted as a rustup toolchain
271           name (such as +stable or +nightly). See the rustup documentation
272           <https://rust-lang.github.io/rustup/overrides.html> for more
273           information about how toolchain overrides work.
274
275       --config KEY=VALUE or PATH
276           Overrides a Cargo configuration value. The argument should be in
277           TOML syntax of KEY=VALUE, or provided as a path to an extra
278           configuration file. This flag may be specified multiple times. See
279           the command-line overrides section
280           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
281           for more information.
282
283       -C PATH
284           Changes the current working directory before executing any specified
285           operations. This affects things like where cargo looks by default
286           for the project manifest (Cargo.toml), as well as the directories
287           searched for discovering .cargo/config.toml, for example. This
288           option must appear before the command name, for example cargo -C
289           path/to/my-project build.
290
291           This option is only available on the nightly channel
292           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
293           requires the -Z unstable-options flag to enable (see #10098
294           <https://github.com/rust-lang/cargo/issues/10098>).
295
296       -h, --help
297           Prints help information.
298
299       -Z flag
300           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
301           details.
302
303ENVIRONMENT
304       See the reference
305       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
306       for details on environment variables that Cargo reads.
307
308EXIT STATUS
309       o  0: Cargo succeeded.
310
311       o  101: Cargo failed to complete.
312
313EXAMPLES
314       1. Publish the current package:
315
316              cargo publish
317
318SEE ALSO
319       cargo(1), cargo-package(1), cargo-login(1)
320