table of contents
CARGO-RUN(1) | CARGO-RUN(1) |
NAME¶
cargo-run - Run the current package
SYNOPSIS¶
cargo run [OPTIONS] [-- ARGS]
DESCRIPTION¶
Run a binary or example of the local package.
All the arguments following the two dashes (--) are passed to the binary to run. If you’re passing arguments to both Cargo and the binary, the ones after -- go to the binary, the ones before go to Cargo.
OPTIONS¶
Package Selection¶
By default, the package in the current working directory is selected. The -p flag can be used to choose a different package in a workspace.
-p SPEC, --package SPEC
Target Selection¶
When no target selection options are given, cargo run will run the binary target. If there are multiple binary targets, you must pass a target flag to choose one. Or, the default-run field may be specified in the [package] section of Cargo.toml to choose the name of the binary to run by default.
--bin NAME
--example NAME
Feature Selection¶
The feature flags allow you to control the enabled features for the "current" package. The "current" package is the package in the current directory, or the one specified in --manifest-path. If running in the root of a virtual workspace, then the default features are selected for all workspace members, or all features if --all-features is specified.
When no feature options are given, the default feature is activated for every selected package.
--features FEATURES
--all-features
--no-default-features
Compilation Options¶
--target TRIPLE
This may also be specified with the build.target config value <https://doc.rust-lang.org/cargo/reference/config.html>.
Note that specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the build cache <https://doc.rust-lang.org/cargo/guide/build-cache.html> documentation for more details.
--release
Output Options¶
--target-dir DIRECTORY
Display Options¶
-v, --verbose
-q, --quiet
--color WHEN
May also be specified with the term.color config value <https://doc.rust-lang.org/cargo/reference/config.html>.
--message-format FMT
Manifest Options¶
--manifest-path PATH
--frozen, --locked
These may be used in environments where you want to assert that the Cargo.lock file is up-to-date (such as a CI build) or want to avoid network access.
--offline
Beware that this may result in different dependency resolution than online mode. Cargo will restrict itself to crates that are downloaded locally, even if there might be a newer version as indicated in the local copy of the index. See the cargo-fetch(1) command to download dependencies before going offline.
May also be specified with the net.offline config value <https://doc.rust-lang.org/cargo/reference/config.html>.
Common Options¶
+TOOLCHAIN
-h, --help
-Z FLAG...
Miscellaneous Options¶
-j N, --jobs N
PROFILES¶
Profiles may be used to configure compiler options such as optimization levels and debug settings. See the reference <https://doc.rust-lang.org/cargo/reference/profiles.html> for more details.
Profile selection depends on the target and crate being built. By default the dev or test profiles are used. If the --release flag is given, then the release or bench profiles are used.
Target | Default Profile | --release Profile |
lib, bin, example | dev | release |
test, bench, or any target in "test" or "bench" mode | test | bench |
Dependencies use the dev/release profiles.
ENVIRONMENT¶
See the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads.
EXIT STATUS¶
0
101
EXAMPLES¶
cargo run
cargo run --example exname -- --exoption exarg1 exarg2
SEE ALSO¶
2020-04-21 |