1CARGO-RUN(1)                                                      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 the enabled features for the
42       "current" package. The "current" package is the package in the current
43       directory, or the one specified in --manifest-path. If running in the
44       root of a virtual workspace, then the default features are selected for
45       all workspace members, or all features if --all-features is specified.
46
47       When no feature options are given, the default feature is activated for
48       every selected package.
49
50       --features FEATURES
51           Space or comma separated list of features to activate. These
52           features only apply to the current directory’s package. Features of
53           direct dependencies may be enabled with <dep-name>/<feature-name>
54           syntax. This flag may be specified multiple times, which enables
55           all specified features.
56
57       --all-features
58           Activate all available features of all selected packages.
59
60       --no-default-features
61           Do not activate the default feature of the current directory’s
62           package.
63
64   Compilation Options
65       --target TRIPLE
66           Run for the given architecture. The default is the host
67           architecture. The general format of the triple is
68           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
69           a list of supported targets.
70
71           This may also be specified with the build.target config value
72           <https://doc.rust-lang.org/cargo/reference/config.html>.
73
74           Note that specifying this flag makes Cargo run in a different mode
75           where the target artifacts are placed in a separate directory. See
76           the build cache
77           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
78           documentation for more details.
79
80       --release
81           Run optimized artifacts with the release profile. See the PROFILES
82           section for details on how this affects profile selection.
83
84   Output Options
85       --target-dir DIRECTORY
86           Directory for all generated artifacts and intermediate files. May
87           also be specified with the CARGO_TARGET_DIR environment variable,
88           or the build.target-dir config value
89           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
90           to target in the root of the workspace.
91
92   Display Options
93       -v, --verbose
94           Use verbose output. May be specified twice for "very verbose"
95           output which includes extra output such as dependency warnings and
96           build script output. May also be specified with the term.verbose
97           config value
98           <https://doc.rust-lang.org/cargo/reference/config.html>.
99
100       -q, --quiet
101           No output printed to stdout.
102
103       --color WHEN
104           Control when colored output is used. Valid values:
105
106           ·   auto (default): Automatically detect if color support is
107               available on the terminal.
108
109           ·   always: Always display colors.
110
111           ·   never: Never display colors.
112
113           May also be specified with the term.color config value
114           <https://doc.rust-lang.org/cargo/reference/config.html>.
115
116       --message-format FMT
117           The output format for diagnostic messages. Can be specified
118           multiple times and consists of comma-separated values. Valid
119           values:
120
121           ·   human (default): Display in a human-readable text format.
122
123           ·   short: Emit shorter, human-readable text messages.
124
125           ·   json: Emit JSON messages to stdout. See the reference
126               <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
127               for more details.
128
129           ·   json-diagnostic-short: Ensure the rendered field of JSON
130               messages contains the "short" rendering from rustc.
131
132           ·   json-diagnostic-rendered-ansi: Ensure the rendered field of
133               JSON messages contains embedded ANSI color codes for respecting
134               rustc’s default color scheme.
135
136           ·   json-render-diagnostics: Instruct Cargo to not include rustc
137               diagnostics in in JSON messages printed, but instead Cargo
138               itself should render the JSON diagnostics coming from rustc.
139               Cargo’s own JSON diagnostics and others coming from rustc are
140               still emitted.
141
142   Manifest Options
143       --manifest-path PATH
144           Path to the Cargo.toml file. By default, Cargo searches for the
145           Cargo.toml file in the current directory or any parent directory.
146
147       --frozen, --locked
148           Either of these flags requires that the Cargo.lock file is
149           up-to-date. If the lock file is missing, or it needs to be updated,
150           Cargo will exit with an error. The --frozen flag also prevents
151           Cargo from attempting to access the network to determine if it is
152           out-of-date.
153
154           These may be used in environments where you want to assert that the
155           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
156           network access.
157
158       --offline
159           Prevents Cargo from accessing the network for any reason. Without
160           this flag, Cargo will stop with an error if it needs to access the
161           network and the network is not available. With this flag, Cargo
162           will attempt to proceed without the network if possible.
163
164           Beware that this may result in different dependency resolution than
165           online mode. Cargo will restrict itself to crates that are
166           downloaded locally, even if there might be a newer version as
167           indicated in the local copy of the index. See the cargo-fetch(1)
168           command to download dependencies before going offline.
169
170           May also be specified with the net.offline config value
171           <https://doc.rust-lang.org/cargo/reference/config.html>.
172
173   Common Options
174       -h, --help
175           Prints help information.
176
177       -Z FLAG...
178           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
179           details.
180
181   Miscellaneous Options
182       -j N, --jobs N
183           Number of parallel jobs to run. May also be specified with the
184           build.jobs config value
185           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
186           to the number of CPUs.
187

PROFILES

189       Profiles may be used to configure compiler options such as optimization
190       levels and debug settings. See the reference
191       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
192       details.
193
194       Profile selection depends on the target and crate being built. By
195       default the dev or test profiles are used. If the --release flag is
196       given, then the release or bench profiles are used.
197
198       ┌────────────────────┬─────────────────┬───────────────────┐
199       │                    │                 │                   │
200       │Target              │ Default Profile │ --release Profile │
201       ├────────────────────┼─────────────────┼───────────────────┤
202       │                    │                 │                   │
203       │lib, bin, example   │ dev             release           
204       ├────────────────────┼─────────────────┼───────────────────┤
205       │                    │                 │                   │
206       │test, bench, or any │ test            bench             
207       │target              │                 │                   │
208       │in "test" or        │                 │                   │
209       │"bench" mode        │                 │                   │
210       └────────────────────┴─────────────────┴───────────────────┘
211
212       Dependencies use the dev/release profiles.
213

ENVIRONMENT

215       See the reference
216       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
217       for details on environment variables that Cargo reads.
218

EXIT STATUS

220       0
221           Cargo succeeded.
222
223       101
224           Cargo failed to complete.
225

EXAMPLES

227        1. Build the local package and run its main target (assuming only one
228           binary):
229
230               cargo run
231
232        2. Run an example with extra arguments:
233
234               cargo run --example exname -- --exoption exarg1 exarg2
235

SEE ALSO

237       cargo(1), cargo-build(1)
238
239
240
241                                  2019-11-11                      CARGO-RUN(1)
Impressum