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

PROFILES

174       Profiles may be used to configure compiler options such as optimization
175       levels and debug settings. See the reference
176       <https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections>
177       for more details.
178
179       Profile selection depends on the target and crate being built. By
180       default the dev or test profiles are used. If the --release flag is
181       given, then the release or bench profiles are used.
182
183       ┌────────────────────┬─────────────────┬───────────────────┐
184       │                    │                 │                   │
185       │Target              │ Default Profile │ --release Profile │
186       ├────────────────────┼─────────────────┼───────────────────┤
187       │                    │                 │                   │
188       │lib, bin, example   │ dev             release           
189       ├────────────────────┼─────────────────┼───────────────────┤
190       │                    │                 │                   │
191       │test, bench, or any │ test            bench             
192       │target              │                 │                   │
193       │in "test" or        │                 │                   │
194       │"bench" mode        │                 │                   │
195       └────────────────────┴─────────────────┴───────────────────┘
196
197       Dependencies use the dev/release profiles.
198

ENVIRONMENT

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

EXIT STATUS

205       0
206           Cargo succeeded.
207
208       101
209           Cargo failed to complete.
210

EXAMPLES

212        1. Build the local package and run its main target (assuming only one
213           binary):
214
215               cargo run
216
217        2. Run an example with extra arguments:
218
219               cargo run --example exname -- --exoption exarg1 exarg2
220

SEE ALSO

222       cargo(1), cargo-build(1)
223
224
225
226                                  2019-07-15                      CARGO-RUN(1)
Impressum