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.
31
32       --bin NAME
33           Run the specified binary.
34
35       --example NAME
36           Run the specified example.
37
38   Feature Selection
39       When no feature options are given, the default feature is activated for
40       every selected package.
41
42       --features FEATURES
43           Space or comma separated list of features to activate. These
44           features only apply to the current directory’s package. Features of
45           direct dependencies may be enabled with <dep-name>/<feature-name>
46           syntax.
47
48       --all-features
49           Activate all available features of all selected packages.
50
51       --no-default-features
52           Do not activate the default feature of the current directory’s
53           package.
54
55   Compilation Options
56       --target TRIPLE
57           Run for the given architecture. The default is the host
58           architecture. The general format of the triple is
59           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
60           a list of supported targets.
61
62           This may also be specified with the build.target config value
63           <https://doc.rust-lang.org/cargo/reference/config.html>.
64
65       --release
66           Run optimized artifacts with the release profile. See the PROFILES
67           section for details on how this affects profile selection.
68
69   Output Options
70       --target-dir DIRECTORY
71           Directory for all generated artifacts and intermediate files. May
72           also be specified with the CARGO_TARGET_DIR environment variable,
73           or the build.target-dir config value
74           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
75           to target in the root of the workspace.
76
77   Display Options
78       -v, --verbose
79           Use verbose output. May be specified twice for "very verbose"
80           output which includes extra output such as dependency warnings and
81           build script output. May also be specified with the term.verbose
82           config value
83           <https://doc.rust-lang.org/cargo/reference/config.html>.
84
85       -q, --quiet
86           No output printed to stdout.
87
88       --color WHEN
89           Control when colored output is used. Valid values:
90
91           ·   auto (default): Automatically detect if color support is
92               available on the terminal.
93
94           ·   always: Always display colors.
95
96           ·   never: Never display colors.
97
98           May also be specified with the term.color config value
99           <https://doc.rust-lang.org/cargo/reference/config.html>.
100
101       --message-format FMT
102           The output format for diagnostic messages. Valid values:
103
104           ·   human (default): Display in a human-readable text format.
105
106           ·   json: Emit JSON messages to stdout.
107
108           ·   short: Emit shorter, human-readable text messages.
109
110   Manifest Options
111       --manifest-path PATH
112           Path to the Cargo.toml file. By default, Cargo searches in the
113           current directory or any parent directory for the Cargo.toml file.
114
115       --frozen, --locked
116           Either of these flags requires that the Cargo.lock file is
117           up-to-date. If the lock file is missing, or it needs to be updated,
118           Cargo will exit with an error. The --frozen flag also prevents
119           Cargo from attempting to access the network to determine if it is
120           out-of-date.
121
122           These may be used in environments where you want to assert that the
123           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
124           network access.
125
126   Common Options
127       -h, --help
128           Prints help information.
129
130       -Z FLAG...
131           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
132           details.
133
134   Miscellaneous Options
135       -j N, --jobs N
136           Number of parallel jobs to run. May also be specified with the
137           build.jobs config value
138           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
139           to the number of CPUs.
140

PROFILES

142       Profiles may be used to configure compiler options such as optimization
143       levels and debug settings. See the reference
144       <https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections>
145       for more details.
146
147       Profile selection depends on the target and crate being built. By
148       default the dev or test profiles are used. If the --release flag is
149       given, then the release or bench profiles are used.
150
151       ┌────────────────────┬─────────────────┬───────────────────┐
152       │                    │                 │                   │
153       │Target              │ Default Profile │ --release Profile │
154       ├────────────────────┼─────────────────┼───────────────────┤
155       │                    │                 │                   │
156       │lib, bin, example   │ dev             release           
157       ├────────────────────┼─────────────────┼───────────────────┤
158       │                    │                 │                   │
159       │test, bench, or any │ test            bench             
160       │target              │                 │                   │
161       │in "test" or        │                 │                   │
162       │"bench" mode        │                 │                   │
163       └────────────────────┴─────────────────┴───────────────────┘
164
165       Dependencies use the dev/release profiles.
166

ENVIRONMENT

168       See the reference
169       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
170       for details on environment variables that Cargo reads.
171

EXIT STATUS

173       0
174           Cargo succeeded.
175
176       101
177           Cargo failed to complete.
178

EXAMPLES

180        1. Build the local package and run its main target (assuming only one
181           binary):
182
183               cargo run
184
185        2. Run an example with extra arguments:
186
187               cargo run --example exname -- --exoption exarg1 exarg2
188

SEE ALSO

190       cargo(1), cargo-build(1)
191
192
193
194                                  2019-02-05                      CARGO-RUN(1)
Impressum