1CARGO(1) CARGO(1)
2
3
4
6 cargo - The Rust package manager
7
9 cargo [OPTIONS] COMMAND [ARGS]
10 cargo [OPTIONS] --version
11 cargo [OPTIONS] --list
12 cargo [OPTIONS] --help
13 cargo [OPTIONS] --explain CODE
14
16 This program is a package manager and build tool for the Rust language,
17 available at https://rust-lang.org.
18
20 Build Commands
21 cargo-bench(1)
22 Execute benchmarks of a package.
23
24 cargo-build(1)
25 Compile a package.
26
27 cargo-check(1)
28 Check a local package and all of its dependencies for errors.
29
30 cargo-clean(1)
31 Remove artifacts that Cargo has generated in the past.
32
33 cargo-doc(1)
34 Build a package’s documentation.
35
36 cargo-fetch(1)
37 Fetch dependencies of a package from the network.
38
39 cargo-fix(1)
40 Automatically fix lint warnings reported by rustc.
41
42 cargo-run(1)
43 Run a binary or example of the local package.
44
45 cargo-rustc(1)
46 Compile a package, and pass extra options to the compiler.
47
48 cargo-rustdoc(1)
49 Build a package’s documentation, using specified custom flags.
50
51 cargo-test(1)
52 Execute unit and integration tests of a package.
53
54 Manifest Commands
55 cargo-generate-lockfile(1)
56 Generate Cargo.lock for a project.
57
58 cargo-locate-project(1)
59 Print a JSON representation of a Cargo.toml file’s location.
60
61 cargo-metadata(1)
62 Output the resolved dependencies of a package, the concrete used
63 versions including overrides, in machine-readable format.
64
65 cargo-pkgid(1)
66 Print a fully qualified package specification.
67
68 cargo-update(1)
69 Update dependencies as recorded in the local lock file.
70
71 cargo-verify-project(1)
72 Check correctness of crate manifest.
73
74 Package Commands
75 cargo-init(1)
76 Create a new Cargo package in an existing directory.
77
78 cargo-install(1)
79 Build and install a Rust binary.
80
81 cargo-new(1)
82 Create a new Cargo package.
83
84 cargo-search(1)
85 Search packages in crates.io.
86
87 cargo-uninstall(1)
88 Remove a Rust binary.
89
90 Publishing Commands
91 cargo-login(1)
92 Save an API token from the registry locally.
93
94 cargo-owner(1)
95 Manage the owners of a crate on the registry.
96
97 cargo-package(1)
98 Assemble the local package into a distributable tarball.
99
100 cargo-publish(1)
101 Upload a package to the registry.
102
103 cargo-yank(1)
104 Remove a pushed crate from the index.
105
106 General Commands
107 cargo-help(1)
108 Display help information about Cargo.
109
110 cargo-version(1)
111 Show version information.
112
114 Special Options
115 -V, --version
116 Print version info and exit. If used with --verbose, prints extra
117 information.
118
119 --list
120 List all installed Cargo subcommands. If used with --verbose,
121 prints extra information.
122
123 --explain CODE
124 Run rustc --explain CODE which will print out a detailed
125 explanation of an error message (for example, E0004).
126
127 Display Options
128 -v, --verbose
129 Use verbose output. May be specified twice for "very verbose"
130 output which includes extra output such as dependency warnings and
131 build script output. May also be specified with the term.verbose
132 config value
133 <https://doc.rust-lang.org/cargo/reference/config.html>.
134
135 -q, --quiet
136 No output printed to stdout.
137
138 --color WHEN
139 Control when colored output is used. Valid values:
140
141 · auto (default): Automatically detect if color support is
142 available on the terminal.
143
144 · always: Always display colors.
145
146 · never: Never display colors.
147
148 May also be specified with the term.color config value
149 <https://doc.rust-lang.org/cargo/reference/config.html>.
150
151 Manifest Options
152 --frozen, --locked
153 Either of these flags requires that the Cargo.lock file is
154 up-to-date. If the lock file is missing, or it needs to be updated,
155 Cargo will exit with an error. The --frozen flag also prevents
156 Cargo from attempting to access the network to determine if it is
157 out-of-date.
158
159 These may be used in environments where you want to assert that the
160 Cargo.lock file is up-to-date (such as a CI build) or want to avoid
161 network access.
162
163 Common Options
164 -h, --help
165 Prints help information.
166
167 -Z FLAG...
168 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
169 details.
170
172 See the reference
173 <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
174 for details on environment variables that Cargo reads.
175
177 0
178 Cargo succeeded.
179
180 101
181 Cargo failed to complete.
182
184 ~/.cargo/
185 Default location for Cargo’s "home" directory where it stores
186 various files. The location can be changed with the CARGO_HOME
187 environment variable.
188
189 $CARGO_HOME/bin/
190 Binaries installed by cargo-install(1) will be located here. If
191 using rustup, executables distributed with Rust are also located
192 here.
193
194 $CARGO_HOME/config
195 The global configuration file. See the reference
196 <https://doc.rust-lang.org/cargo/reference/config.html> for more
197 information about configuration files.
198
199 .cargo/config
200 Cargo automatically searches for a file named .cargo/config in the
201 current directory, and all parent directories. These configuration
202 files will be merged with the global configuration file.
203
204 $CARGO_HOME/credentials
205 Private authentication information for logging in to a registry.
206
207 $CARGO_HOME/registry/
208 This directory contains cached downloads of the registry index and
209 any downloaded dependencies.
210
211 $CARGO_HOME/git/
212 This directory contains cached downloads of git dependencies.
213
215 1. Build a local package and all of its dependencies:
216
217 cargo build
218
219 2. Build a package with optimizations:
220
221 cargo build --release
222
223 3. Run tests for a cross-compiled target:
224
225 cargo test --target i686-unknown-linux-gnu
226
227 4. Create a new package that builds an executable:
228
229 cargo new foobar
230
231 5. Create a package in the current directory:
232
233 mkdir foo && cd foo
234 cargo init .
235
236 6. Learn about a command’s options and usage:
237
238 cargo help clean
239
241 See https://github.com/rust-lang/cargo/issues for issues.
242
244 rustc(1), rustdoc(1)
245
246
247
248 2019-02-05 CARGO(1)