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

NAME

6       cargo-run - Run the current package
7

SYNOPSIS

9       cargo run [options] [-- args]
10

DESCRIPTION

12       Run a binary or example of the local package.
13
14       All the arguments following the two dashes (--) are passed to the
15       binary to run. If you're passing arguments to both Cargo and the
16       binary, the ones after -- go to the binary, the ones before go to
17       Cargo.
18

OPTIONS

20   Package Selection
21       By default, the package in the current working directory is selected.
22       The -p flag can be used to choose a different package in a workspace.
23
24       -p spec, --package spec
25           The package to run. See cargo-pkgid(1) for the SPEC format.
26
27   Target Selection
28       When no target selection options are given, cargo run will run the
29       binary target. If there are multiple binary targets, you must pass a
30       target flag to choose one. Or, the default-run field may be specified
31       in the [package] section of Cargo.toml to choose the name of the binary
32       to run by default.
33
34       --bin name
35           Run the specified binary.
36
37       --example name
38           Run the specified example.
39
40   Feature Selection
41       The feature flags allow you to control which features are enabled. When
42       no feature options are given, the default feature is activated for
43       every selected package.
44
45       See the features documentation
46       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
47       for more details.
48
49       -F features, --features features
50           Space or comma separated list of features to activate. Features of
51           workspace members may be enabled with package-name/feature-name
52           syntax. This flag may be specified multiple times, which enables
53           all specified features.
54
55       --all-features
56           Activate all available features of all selected packages.
57
58       --no-default-features
59           Do not activate the default feature of the selected packages.
60
61   Compilation Options
62       --target triple
63           Run for the given architecture. The default is the host
64           architecture. The general format of the triple is
65           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
66           a list of supported targets.
67
68           This may also be specified with the build.target config value
69           <https://doc.rust-lang.org/cargo/reference/config.html>.
70
71           Note that specifying this flag makes Cargo run in a different mode
72           where the target artifacts are placed in a separate directory. See
73           the build cache
74           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
75           documentation for more details.
76
77       -r, --release
78           Run optimized artifacts with the release profile. See also the
79           --profile option for choosing a specific profile by name.
80
81       --profile name
82           Run with the given profile. See the the reference
83           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
84           details on profiles.
85
86       --ignore-rust-version
87           Run the target even if the selected Rust compiler is older than the
88           required Rust version as configured in the project's rust-version
89           field.
90
91       --timings=fmts
92           Output information how long each compilation takes, and track
93           concurrency information over time. Accepts an optional
94           comma-separated list of output formats; --timings without an
95           argument will default to --timings=html. Specifying an output
96           format (rather than the default) is unstable and requires
97           -Zunstable-options. Valid output formats:
98
99html (unstable, requires -Zunstable-options): Write a
100               human-readable file cargo-timing.html to the
101               target/cargo-timings directory with a report of the
102               compilation. Also write a report to the same directory with a
103               timestamp in the filename if you want to look at older runs.
104               HTML output is suitable for human consumption only, and does
105               not provide machine-readable timing data.
106
107json (unstable, requires -Zunstable-options): Emit
108               machine-readable JSON information about timing information.
109
110   Output Options
111       --target-dir directory
112           Directory for all generated artifacts and intermediate files. May
113           also be specified with the CARGO_TARGET_DIR environment variable,
114           or the build.target-dir config value
115           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
116           to target in the root of the workspace.
117
118   Display Options
119       -v, --verbose
120           Use verbose output. May be specified twice for "very verbose"
121           output which includes extra output such as dependency warnings and
122           build script output. May also be specified with the term.verbose
123           config value
124           <https://doc.rust-lang.org/cargo/reference/config.html>.
125
126       -q, --quiet
127           Do not print cargo log messages. May also be specified with the
128           term.quiet config value
129           <https://doc.rust-lang.org/cargo/reference/config.html>.
130
131       --color when
132           Control when colored output is used. Valid values:
133
134auto (default): Automatically detect if color support is
135               available on the terminal.
136
137always: Always display colors.
138
139never: Never display colors.
140
141           May also be specified with the term.color config value
142           <https://doc.rust-lang.org/cargo/reference/config.html>.
143
144       --message-format fmt
145           The output format for diagnostic messages. Can be specified
146           multiple times and consists of comma-separated values. Valid
147           values:
148
149human (default): Display in a human-readable text format.
150               Conflicts with short and json.
151
152short: Emit shorter, human-readable text messages. Conflicts
153               with human and json.
154
155json: Emit JSON messages to stdout. See the reference
156               <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
157               for more details. Conflicts with human and short.
158
159json-diagnostic-short: Ensure the rendered field of JSON
160               messages contains the "short" rendering from rustc. Cannot be
161               used with human or short.
162
163json-diagnostic-rendered-ansi: Ensure the rendered field of JSON
164               messages contains embedded ANSI color codes for respecting
165               rustc's default color scheme. Cannot be used with human or
166               short.
167
168json-render-diagnostics: Instruct Cargo to not include rustc
169               diagnostics in JSON messages printed, but instead Cargo itself
170               should render the JSON diagnostics coming from rustc. Cargo's
171               own JSON diagnostics and others coming from rustc are still
172               emitted. Cannot be used with human or short.
173
174   Manifest Options
175       --manifest-path path
176           Path to the Cargo.toml file. By default, Cargo searches for the
177           Cargo.toml file in the current directory or any parent directory.
178
179       --frozen, --locked
180           Either of these flags requires that the Cargo.lock file is
181           up-to-date. If the lock file is missing, or it needs to be updated,
182           Cargo will exit with an error. The --frozen flag also prevents
183           Cargo from attempting to access the network to determine if it is
184           out-of-date.
185
186           These may be used in environments where you want to assert that the
187           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
188           network access.
189
190       --offline
191           Prevents Cargo from accessing the network for any reason. Without
192           this flag, Cargo will stop with an error if it needs to access the
193           network and the network is not available. With this flag, Cargo
194           will attempt to proceed without the network if possible.
195
196           Beware that this may result in different dependency resolution than
197           online mode. Cargo will restrict itself to crates that are
198           downloaded locally, even if there might be a newer version as
199           indicated in the local copy of the index. See the cargo-fetch(1)
200           command to download dependencies before going offline.
201
202           May also be specified with the net.offline config value
203           <https://doc.rust-lang.org/cargo/reference/config.html>.
204
205   Common Options
206       +toolchain
207           If Cargo has been installed with rustup, and the first argument to
208           cargo begins with +, it will be interpreted as a rustup toolchain
209           name (such as +stable or +nightly). See the rustup documentation
210           <https://rust-lang.github.io/rustup/overrides.html> for more
211           information about how toolchain overrides work.
212
213       --config KEY=VALUE or PATH
214           Overrides a Cargo configuration value. The argument should be in
215           TOML syntax of KEY=VALUE, or provided as a path to an extra
216           configuration file. This flag may be specified multiple times. See
217           the command-line overrides section
218           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
219           for more information.
220
221       -h, --help
222           Prints help information.
223
224       -Z flag
225           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
226           details.
227
228   Miscellaneous Options
229       -j N, --jobs N
230           Number of parallel jobs to run. May also be specified with the
231           build.jobs config value
232           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
233           to the number of logical CPUs. If negative, it sets the maximum
234           number of parallel jobs to the number of logical CPUs plus provided
235           value. Should not be 0.
236
237       --keep-going
238           Build as many crates in the dependency graph as possible, rather
239           than aborting the build on the first one that fails to build.
240           Unstable, requires -Zunstable-options.
241

ENVIRONMENT

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

EXIT STATUS

2480: Cargo succeeded.
249
250101: Cargo failed to complete.
251

EXAMPLES

253        1. Build the local package and run its main target (assuming only one
254           binary):
255
256               cargo run
257
258        2. Run an example with extra arguments:
259
260               cargo run --example exname -- --exoption exarg1 exarg2
261

SEE ALSO

263       cargo(1), cargo-build(1)
264
265
266
267                                                                  CARGO-RUN(1)
Impressum