table of contents
CARGO-RUN(1) | CARGO-RUN(1) |
NAME¶
cargo-run - Run the current packageSYNOPSIS¶
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¶
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 TRIPLEThis 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 DIRECTORYDisplay 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¶
-h, --help-Z FLAG...
Miscellaneous Options¶
-j N, --jobs NPROFILES¶
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¶
0101
EXAMPLES¶
cargo run
cargo run --example exname -- --exoption exarg1 exarg2
SEE ALSO¶
cargo(1), cargo-build(1)2019-11-11 |