diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 4da36ab6d94..9e5eb70ceb8 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -476,14 +476,7 @@ See 'cargo help ' for more information on a specific command.\n", .arg(flag("frozen", "Require Cargo.lock and cache are up to date").global(true)) .arg(flag("locked", "Require Cargo.lock is up to date").global(true)) .arg(flag("offline", "Run without accessing the network").global(true)) - .arg( - multi_opt( - "config", - "KEY=VALUE", - "Override a configuration value (unstable)", - ) - .global(true), - ) + .arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true)) .arg( Arg::new("unstable-features") .help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details") diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/config/mod.rs index e20004c0dcc..83eff3cbf57 100644 --- a/src/cargo/util/config/mod.rs +++ b/src/cargo/util/config/mod.rs @@ -892,7 +892,6 @@ impl Config { self.unstable_flags_cli = Some(unstable_flags.to_vec()); } if !cli_config.is_empty() { - self.unstable_flags.fail_if_stable_opt("--config", 6699)?; self.cli_config = Some(cli_config.iter().map(|s| s.to_string()).collect()); self.merge_cli_args()?; } @@ -1165,6 +1164,7 @@ impl Config { Some(cli_args) => cli_args, None => return Ok(loaded_args), }; + let mut seen = HashSet::new(); for arg in cli_args { let arg_as_path = self.cwd.join(arg); let tmp_table = if !arg.is_empty() && arg_as_path.exists() { @@ -1175,9 +1175,8 @@ impl Config { anyhow::format_err!("config path {:?} is not utf-8", arg_as_path) })? .to_string(); - let value = CV::String(str_path, Definition::Cli); - let map = HashMap::from([("include".to_string(), value)]); - CV::Table(map, Definition::Cli) + self._load_file(&self.cwd().join(&str_path), &mut seen, true) + .with_context(|| format!("failed to load config from `{}`", str_path))? } else { // We only want to allow "dotted key" (see https://toml.io/en/v1.0.0#keys) // expressions followed by a value that's not an "inline table" diff --git a/src/doc/man/generated_txt/cargo-add.txt b/src/doc/man/generated_txt/cargo-add.txt index e7abc000cf0..f4a5a14e980 100644 --- a/src/doc/man/generated_txt/cargo-add.txt +++ b/src/doc/man/generated_txt/cargo-add.txt @@ -141,6 +141,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-bench.txt b/src/doc/man/generated_txt/cargo-bench.txt index 972bed35332..01afc593cac 100644 --- a/src/doc/man/generated_txt/cargo-bench.txt +++ b/src/doc/man/generated_txt/cargo-bench.txt @@ -353,6 +353,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-build.txt b/src/doc/man/generated_txt/cargo-build.txt index 818dee1d92d..17802b7fe6d 100644 --- a/src/doc/man/generated_txt/cargo-build.txt +++ b/src/doc/man/generated_txt/cargo-build.txt @@ -302,6 +302,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-check.txt b/src/doc/man/generated_txt/cargo-check.txt index 326c6588d8b..2efb2edc87e 100644 --- a/src/doc/man/generated_txt/cargo-check.txt +++ b/src/doc/man/generated_txt/cargo-check.txt @@ -287,6 +287,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-clean.txt b/src/doc/man/generated_txt/cargo-clean.txt index bec65ca1198..a4888cfdfc4 100644 --- a/src/doc/man/generated_txt/cargo-clean.txt +++ b/src/doc/man/generated_txt/cargo-clean.txt @@ -118,6 +118,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-doc.txt b/src/doc/man/generated_txt/cargo-doc.txt index f5457629cf6..b57035384c1 100644 --- a/src/doc/man/generated_txt/cargo-doc.txt +++ b/src/doc/man/generated_txt/cargo-doc.txt @@ -258,6 +258,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-fetch.txt b/src/doc/man/generated_txt/cargo-fetch.txt index 7c97d01d275..afd3fc37791 100644 --- a/src/doc/man/generated_txt/cargo-fetch.txt +++ b/src/doc/man/generated_txt/cargo-fetch.txt @@ -103,6 +103,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-fix.txt b/src/doc/man/generated_txt/cargo-fix.txt index 0b5ada717b5..c5520bb6e34 100644 --- a/src/doc/man/generated_txt/cargo-fix.txt +++ b/src/doc/man/generated_txt/cargo-fix.txt @@ -360,6 +360,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-generate-lockfile.txt b/src/doc/man/generated_txt/cargo-generate-lockfile.txt index 13f11379018..8ec1547cd63 100644 --- a/src/doc/man/generated_txt/cargo-generate-lockfile.txt +++ b/src/doc/man/generated_txt/cargo-generate-lockfile.txt @@ -79,6 +79,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-init.txt b/src/doc/man/generated_txt/cargo-init.txt index f95348a66dc..ee4077e6776 100644 --- a/src/doc/man/generated_txt/cargo-init.txt +++ b/src/doc/man/generated_txt/cargo-init.txt @@ -87,6 +87,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-install.txt b/src/doc/man/generated_txt/cargo-install.txt index 6132721e7f7..f835b6f0c4a 100644 --- a/src/doc/man/generated_txt/cargo-install.txt +++ b/src/doc/man/generated_txt/cargo-install.txt @@ -323,6 +323,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-locate-project.txt b/src/doc/man/generated_txt/cargo-locate-project.txt index 38cbe96304e..1abff535779 100644 --- a/src/doc/man/generated_txt/cargo-locate-project.txt +++ b/src/doc/man/generated_txt/cargo-locate-project.txt @@ -62,6 +62,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-login.txt b/src/doc/man/generated_txt/cargo-login.txt index 888a1010066..847b7ec72d4 100644 --- a/src/doc/man/generated_txt/cargo-login.txt +++ b/src/doc/man/generated_txt/cargo-login.txt @@ -62,6 +62,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-metadata.txt b/src/doc/man/generated_txt/cargo-metadata.txt index 3fdff6d36fd..11e3a29bd20 100644 --- a/src/doc/man/generated_txt/cargo-metadata.txt +++ b/src/doc/man/generated_txt/cargo-metadata.txt @@ -391,6 +391,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-new.txt b/src/doc/man/generated_txt/cargo-new.txt index 1cb22b57cb3..e881418955a 100644 --- a/src/doc/man/generated_txt/cargo-new.txt +++ b/src/doc/man/generated_txt/cargo-new.txt @@ -82,6 +82,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-owner.txt b/src/doc/man/generated_txt/cargo-owner.txt index ac3b19bf708..269c988227a 100644 --- a/src/doc/man/generated_txt/cargo-owner.txt +++ b/src/doc/man/generated_txt/cargo-owner.txt @@ -89,6 +89,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-package.txt b/src/doc/man/generated_txt/cargo-package.txt index a0a3fc64ec4..89a6b652d93 100644 --- a/src/doc/man/generated_txt/cargo-package.txt +++ b/src/doc/man/generated_txt/cargo-package.txt @@ -227,6 +227,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-pkgid.txt b/src/doc/man/generated_txt/cargo-pkgid.txt index 41ea578d19e..8c8e4f50afd 100644 --- a/src/doc/man/generated_txt/cargo-pkgid.txt +++ b/src/doc/man/generated_txt/cargo-pkgid.txt @@ -109,6 +109,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-publish.txt b/src/doc/man/generated_txt/cargo-publish.txt index 1328ab7ec0b..fc63a9c0a2d 100644 --- a/src/doc/man/generated_txt/cargo-publish.txt +++ b/src/doc/man/generated_txt/cargo-publish.txt @@ -194,6 +194,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-run.txt b/src/doc/man/generated_txt/cargo-run.txt index 96c3feece6f..2d0e607b7b3 100644 --- a/src/doc/man/generated_txt/cargo-run.txt +++ b/src/doc/man/generated_txt/cargo-run.txt @@ -203,6 +203,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-rustc.txt b/src/doc/man/generated_txt/cargo-rustc.txt index aab1921bf59..b0f2ff3f622 100644 --- a/src/doc/man/generated_txt/cargo-rustc.txt +++ b/src/doc/man/generated_txt/cargo-rustc.txt @@ -291,6 +291,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-rustdoc.txt b/src/doc/man/generated_txt/cargo-rustdoc.txt index 66f16c13ace..b45e229a8a9 100644 --- a/src/doc/man/generated_txt/cargo-rustdoc.txt +++ b/src/doc/man/generated_txt/cargo-rustdoc.txt @@ -274,6 +274,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-search.txt b/src/doc/man/generated_txt/cargo-search.txt index 2e2e8d22daf..5abaa85aa27 100644 --- a/src/doc/man/generated_txt/cargo-search.txt +++ b/src/doc/man/generated_txt/cargo-search.txt @@ -59,6 +59,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-test.txt b/src/doc/man/generated_txt/cargo-test.txt index 0c66532da73..d0fe9df36a0 100644 --- a/src/doc/man/generated_txt/cargo-test.txt +++ b/src/doc/man/generated_txt/cargo-test.txt @@ -371,6 +371,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-tree.txt b/src/doc/man/generated_txt/cargo-tree.txt index d6f6c39ec66..0b35d8ab0d0 100644 --- a/src/doc/man/generated_txt/cargo-tree.txt +++ b/src/doc/man/generated_txt/cargo-tree.txt @@ -269,6 +269,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-uninstall.txt b/src/doc/man/generated_txt/cargo-uninstall.txt index 7e55fca19f9..0bebe8c3fd5 100644 --- a/src/doc/man/generated_txt/cargo-uninstall.txt +++ b/src/doc/man/generated_txt/cargo-uninstall.txt @@ -71,6 +71,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-update.txt b/src/doc/man/generated_txt/cargo-update.txt index e1de455bde4..c1e27443669 100644 --- a/src/doc/man/generated_txt/cargo-update.txt +++ b/src/doc/man/generated_txt/cargo-update.txt @@ -109,6 +109,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-vendor.txt b/src/doc/man/generated_txt/cargo-vendor.txt index cfda5c3c808..aafeaaa9e75 100644 --- a/src/doc/man/generated_txt/cargo-vendor.txt +++ b/src/doc/man/generated_txt/cargo-vendor.txt @@ -105,6 +105,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-verify-project.txt b/src/doc/man/generated_txt/cargo-verify-project.txt index 22e4e950e02..7b0f30fc651 100644 --- a/src/doc/man/generated_txt/cargo-verify-project.txt +++ b/src/doc/man/generated_txt/cargo-verify-project.txt @@ -82,6 +82,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-yank.txt b/src/doc/man/generated_txt/cargo-yank.txt index 8ad8ca81c77..cd6bc2be4e6 100644 --- a/src/doc/man/generated_txt/cargo-yank.txt +++ b/src/doc/man/generated_txt/cargo-yank.txt @@ -85,6 +85,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo.txt b/src/doc/man/generated_txt/cargo.txt index 91d9bcf7839..d44cb2aed6a 100644 --- a/src/doc/man/generated_txt/cargo.txt +++ b/src/doc/man/generated_txt/cargo.txt @@ -188,6 +188,9 @@ OPTIONS for more information about how toolchain overrides work. + --config KEY=VALUE + Overrides a Cargo configuration value. + -h, --help Prints help information. diff --git a/src/doc/man/includes/section-options-common.md b/src/doc/man/includes/section-options-common.md index 12a0a5bdadb..1bafb317cbc 100644 --- a/src/doc/man/includes/section-options-common.md +++ b/src/doc/man/includes/section-options-common.md @@ -10,6 +10,10 @@ See the [rustup documentation](https://rust-lang.github.io/rustup/overrides.html for more information about how toolchain overrides work. {{/option}} +{{#option "`--config` KEY=VALUE"}} +Overrides a Cargo configuration value. +{{/option}} + {{#option "`-h`" "`--help`"}} Prints help information. {{/option}} diff --git a/src/doc/src/commands/cargo-add.md b/src/doc/src/commands/cargo-add.md index e7f7e1d5164..619613ba546 100644 --- a/src/doc/src/commands/cargo-add.md +++ b/src/doc/src/commands/cargo-add.md @@ -177,6 +177,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md index 1e60016b39f..69bee8ddb92 100644 --- a/src/doc/src/commands/cargo-bench.md +++ b/src/doc/src/commands/cargo-bench.md @@ -420,6 +420,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-build.md b/src/doc/src/commands/cargo-build.md index 7f6a16a6536..3f473de7a7d 100644 --- a/src/doc/src/commands/cargo-build.md +++ b/src/doc/src/commands/cargo-build.md @@ -364,6 +364,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-check.md b/src/doc/src/commands/cargo-check.md index 967b4cb3adb..7ea0651901a 100644 --- a/src/doc/src/commands/cargo-check.md +++ b/src/doc/src/commands/cargo-check.md @@ -345,6 +345,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-clean.md b/src/doc/src/commands/cargo-clean.md index 86b188b656a..d2e46620471 100644 --- a/src/doc/src/commands/cargo-clean.md +++ b/src/doc/src/commands/cargo-clean.md @@ -149,6 +149,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-doc.md b/src/doc/src/commands/cargo-doc.md index f0927484d65..b28020c9d74 100644 --- a/src/doc/src/commands/cargo-doc.md +++ b/src/doc/src/commands/cargo-doc.md @@ -319,6 +319,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-fetch.md b/src/doc/src/commands/cargo-fetch.md index 0a6a7224f9f..7cdd4543e13 100644 --- a/src/doc/src/commands/cargo-fetch.md +++ b/src/doc/src/commands/cargo-fetch.md @@ -123,6 +123,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-fix.md b/src/doc/src/commands/cargo-fix.md index d871cb10997..d75d81a44bf 100644 --- a/src/doc/src/commands/cargo-fix.md +++ b/src/doc/src/commands/cargo-fix.md @@ -425,6 +425,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-generate-lockfile.md b/src/doc/src/commands/cargo-generate-lockfile.md index 20189031d6d..a608cb2bcf0 100644 --- a/src/doc/src/commands/cargo-generate-lockfile.md +++ b/src/doc/src/commands/cargo-generate-lockfile.md @@ -98,6 +98,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-init.md b/src/doc/src/commands/cargo-init.md index 3cd8e46a3c6..267b6d59445 100644 --- a/src/doc/src/commands/cargo-init.md +++ b/src/doc/src/commands/cargo-init.md @@ -111,6 +111,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-install.md b/src/doc/src/commands/cargo-install.md index 68ddf93da84..fc6678ff3e6 100644 --- a/src/doc/src/commands/cargo-install.md +++ b/src/doc/src/commands/cargo-install.md @@ -373,6 +373,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-locate-project.md b/src/doc/src/commands/cargo-locate-project.md index 600d9a7b0cf..bb363cc0132 100644 --- a/src/doc/src/commands/cargo-locate-project.md +++ b/src/doc/src/commands/cargo-locate-project.md @@ -87,6 +87,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-login.md b/src/doc/src/commands/cargo-login.md index 65468249876..590b99e205b 100644 --- a/src/doc/src/commands/cargo-login.md +++ b/src/doc/src/commands/cargo-login.md @@ -79,6 +79,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-metadata.md b/src/doc/src/commands/cargo-metadata.md index 8b5f5b2123e..cd62d1b0b9a 100644 --- a/src/doc/src/commands/cargo-metadata.md +++ b/src/doc/src/commands/cargo-metadata.md @@ -427,6 +427,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-new.md b/src/doc/src/commands/cargo-new.md index 89f26c65bf4..4763e079b34 100644 --- a/src/doc/src/commands/cargo-new.md +++ b/src/doc/src/commands/cargo-new.md @@ -106,6 +106,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-owner.md b/src/doc/src/commands/cargo-owner.md index 9d6998bb203..851c1936861 100644 --- a/src/doc/src/commands/cargo-owner.md +++ b/src/doc/src/commands/cargo-owner.md @@ -117,6 +117,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-package.md b/src/doc/src/commands/cargo-package.md index 5e9e686baa7..568880a0d48 100644 --- a/src/doc/src/commands/cargo-package.md +++ b/src/doc/src/commands/cargo-package.md @@ -280,6 +280,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-pkgid.md b/src/doc/src/commands/cargo-pkgid.md index a6bf95f34ea..23c15eb1631 100644 --- a/src/doc/src/commands/cargo-pkgid.md +++ b/src/doc/src/commands/cargo-pkgid.md @@ -127,6 +127,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-publish.md b/src/doc/src/commands/cargo-publish.md index c494bde3d5d..e4489416e06 100644 --- a/src/doc/src/commands/cargo-publish.md +++ b/src/doc/src/commands/cargo-publish.md @@ -246,6 +246,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-run.md b/src/doc/src/commands/cargo-run.md index f71a769d497..e0fa5ccac3e 100644 --- a/src/doc/src/commands/cargo-run.md +++ b/src/doc/src/commands/cargo-run.md @@ -258,6 +258,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-rustc.md b/src/doc/src/commands/cargo-rustc.md index 6fd56810021..7396d679e2e 100644 --- a/src/doc/src/commands/cargo-rustc.md +++ b/src/doc/src/commands/cargo-rustc.md @@ -347,6 +347,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-rustdoc.md b/src/doc/src/commands/cargo-rustdoc.md index 76e45bb52f3..1fe506d108e 100644 --- a/src/doc/src/commands/cargo-rustdoc.md +++ b/src/doc/src/commands/cargo-rustdoc.md @@ -338,6 +338,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-search.md b/src/doc/src/commands/cargo-search.md index 5a117683b7e..aff276749d0 100644 --- a/src/doc/src/commands/cargo-search.md +++ b/src/doc/src/commands/cargo-search.md @@ -83,6 +83,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-test.md b/src/doc/src/commands/cargo-test.md index a940ff24d56..9ff65a10723 100644 --- a/src/doc/src/commands/cargo-test.md +++ b/src/doc/src/commands/cargo-test.md @@ -443,6 +443,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-tree.md b/src/doc/src/commands/cargo-tree.md index 6a9a73d0290..98a4d55eae9 100644 --- a/src/doc/src/commands/cargo-tree.md +++ b/src/doc/src/commands/cargo-tree.md @@ -313,6 +313,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-uninstall.md b/src/doc/src/commands/cargo-uninstall.md index d4b9f7fe17f..f6a4a13456c 100644 --- a/src/doc/src/commands/cargo-uninstall.md +++ b/src/doc/src/commands/cargo-uninstall.md @@ -93,6 +93,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-update.md b/src/doc/src/commands/cargo-update.md index f5bf623d187..4720b1e5e0b 100644 --- a/src/doc/src/commands/cargo-update.md +++ b/src/doc/src/commands/cargo-update.md @@ -138,6 +138,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-vendor.md b/src/doc/src/commands/cargo-vendor.md index ec689072477..caeca4e85bd 100644 --- a/src/doc/src/commands/cargo-vendor.md +++ b/src/doc/src/commands/cargo-vendor.md @@ -134,6 +134,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-verify-project.md b/src/doc/src/commands/cargo-verify-project.md index 55f8885ca90..0fb3184bcf4 100644 --- a/src/doc/src/commands/cargo-verify-project.md +++ b/src/doc/src/commands/cargo-verify-project.md @@ -104,6 +104,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-yank.md b/src/doc/src/commands/cargo-yank.md index 21c68d14ade..8bf4f825c00 100644 --- a/src/doc/src/commands/cargo-yank.md +++ b/src/doc/src/commands/cargo-yank.md @@ -113,6 +113,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo.md b/src/doc/src/commands/cargo.md index 5a61239e136..f879fa5306c 100644 --- a/src/doc/src/commands/cargo.md +++ b/src/doc/src/commands/cargo.md @@ -221,6 +221,10 @@ See the rustup docum for more information about how toolchain overrides work. +
--config KEY=VALUE
+
Overrides a Cargo configuration value.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md index c2d8e665ef9..f4749457e7a 100644 --- a/src/doc/src/reference/config.md +++ b/src/doc/src/reference/config.md @@ -195,6 +195,46 @@ support environment variables. In addition to the system above, Cargo recognizes a few other specific [environment variables][env]. +### Command-line overrides + +Cargo also accepts arbitrary configuration overrides through the +`--config` command-line option. The argument should be in TOML syntax of +`KEY=VALUE`: + +```console +cargo --config net.git-fetch-with-cli=true fetch +``` + +The `--config` option may be specified multiple times, in which case the +values are merged in left-to-right order, using the same merging logic +that is used when multiple configuration files apply. Configuration +values specified this way take precedence over environment variables, +which take precedence over configuration files. + +Some examples of what it looks like using Bourne shell syntax: + +```console +# Most shells will require escaping. +cargo --config http.proxy=\"http://example.com\" … + +# Spaces may be used. +cargo --config "net.git-fetch-with-cli = true" … + +# TOML array example. Single quotes make it easier to read and write. +cargo --config 'build.rustdocflags = ["--html-in-header", "header.html"]' … + +# Example of a complex TOML key. +cargo --config "target.'cfg(all(target_arch = \"arm\", target_os = \"none\"))'.runner = 'my-runner'" … + +# Example of overriding a profile setting. +cargo --config profile.dev.package.image.opt-level=3 … +``` + +The `--config` option can also be used to pass paths to extra +configuration files that Cargo should use for a specific invocation. +Options from configuration files loaded this way follow the same +precedence rules as other options specified directly with `--config`. + ### Config-relative paths Paths in config files may be absolute, relative, or a bare name without any diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index dd40f25d4e3..945db70afb6 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -96,7 +96,6 @@ Each new feature described below should explain how to use it. * [unit-graph](#unit-graph) — Emits JSON for Cargo's internal graph structure. * [`cargo rustc --print`](#rustc---print) — Calls rustc with `--print` to display information from rustc. * Configuration - * [config-cli](#config-cli) — Adds the ability to pass configuration options on the command-line. * [config-include](#config-include) — Adds the ability for config files to include other files. * [`cargo config`](#cargo-config) — Adds a new subcommand for viewing config files. * Registries @@ -475,40 +474,6 @@ The `-Z unstable-options` command-line option must be used in order to use cargo check --keep-going -Z unstable-options ``` -### config-cli -* Tracking Issue: [#7722](https://github.com/rust-lang/cargo/issues/7722) - -The `--config` CLI option allows arbitrary config values to be passed -in via the command-line. The argument should be in TOML syntax of KEY=VALUE: - -```console -cargo +nightly -Zunstable-options --config net.git-fetch-with-cli=true fetch -``` - -The `--config` option may be specified multiple times, in which case the -values are merged in left-to-right order, using the same merging logic that -multiple config files use. CLI values take precedence over environment -variables, which take precedence over config files. - -Some examples of what it looks like using Bourne shell syntax: - -```console -# Most shells will require escaping. -cargo --config http.proxy=\"http://example.com\" … - -# Spaces may be used. -cargo --config "net.git-fetch-with-cli = true" … - -# TOML array example. Single quotes make it easier to read and write. -cargo --config 'build.rustdocflags = ["--html-in-header", "header.html"]' … - -# Example of a complex TOML key. -cargo --config "target.'cfg(all(target_arch = \"arm\", target_os = \"none\"))'.runner = 'my-runner'" … - -# Example of overriding a profile setting. -cargo --config profile.dev.package.image.opt-level=3 … -``` - ### config-include * Tracking Issue: [#7723](https://github.com/rust-lang/cargo/issues/7723) @@ -1598,3 +1563,9 @@ See the [Features chapter](features.md#dependency-features) for more information The `-Ztimings` option has been stabilized as `--timings` in the 1.60 release. (`--timings=html` and the machine-readable `--timings=json` output remain unstable and require `-Zunstable-options`.) + +### config-cli + +The `--config` CLI option has been stabilized in the 1.63 release. See +the [config documentation](config.html#command-line-overrides) for more +information. diff --git a/src/etc/man/cargo-add.1 b/src/etc/man/cargo-add.1 index f7803405346..959aebe602c 100644 --- a/src/etc/man/cargo-add.1 +++ b/src/etc/man/cargo-add.1 @@ -187,6 +187,11 @@ See the \fIrustup documentation\fR ) -> &mut Self { - if !self.unstable.iter().any(|s| s == "unstable-options") { - // --config is current unstable - self.unstable_flag("unstable-options"); - } self.config_args.push(arg.into()); self } diff --git a/tests/testsuite/config_cli.rs b/tests/testsuite/config_cli.rs index dd08e13d103..e4c593443e7 100644 --- a/tests/testsuite/config_cli.rs +++ b/tests/testsuite/config_cli.rs @@ -2,26 +2,9 @@ use super::config::{assert_error, assert_match, read_output, write_config, ConfigBuilder}; use cargo::util::config::Definition; -use cargo_test_support::{paths, project}; +use cargo_test_support::paths; use std::{collections::HashMap, fs}; -#[cargo_test] -fn config_gated() { - // Requires -Zunstable-options - let p = project().file("src/lib.rs", "").build(); - - p.cargo("build --config --config build.jobs=1") - .with_status(101) - .with_stderr( - "\ -[ERROR] the `--config` flag is unstable, [..] -See [..] -See [..] -", - ) - .run(); -} - #[cargo_test] fn basic() { // Simple example. @@ -472,3 +455,30 @@ Caused by: expected string, but found array", ); } + +#[cargo_test] +fn cli_path() { + // --config path_to_file + fs::write(paths::root().join("myconfig.toml"), "key = 123").unwrap(); + let config = ConfigBuilder::new() + .cwd(paths::root()) + .config_arg("myconfig.toml") + .build(); + assert_eq!(config.get::("key").unwrap(), 123); + + let config = ConfigBuilder::new().config_arg("missing.toml").build_err(); + assert_error( + config.unwrap_err(), + "\ +failed to parse value from --config argument `missing.toml` as a dotted key expression + +Caused by: + TOML parse error at line 1, column 13 + | +1 | missing.toml + | ^ +Unexpected end of input +Expected `.` or `=` +", + ); +} diff --git a/tests/testsuite/config_include.rs b/tests/testsuite/config_include.rs index ac210b777cb..464467aa6eb 100644 --- a/tests/testsuite/config_include.rs +++ b/tests/testsuite/config_include.rs @@ -1,8 +1,7 @@ //! Tests for `include` config field. use super::config::{assert_error, write_config, write_config_at, ConfigBuilder}; -use cargo_test_support::{no_such_file_err_msg, paths, project}; -use std::fs; +use cargo_test_support::{no_such_file_err_msg, project}; #[cargo_test] fn gated() { @@ -255,34 +254,3 @@ Caused by: expected array, but found string", ); } - -#[cargo_test] -fn cli_path() { - // --config path_to_file - fs::write(paths::root().join("myconfig.toml"), "key = 123").unwrap(); - let config = ConfigBuilder::new() - .cwd(paths::root()) - .unstable_flag("config-include") - .config_arg("myconfig.toml") - .build(); - assert_eq!(config.get::("key").unwrap(), 123); - - let config = ConfigBuilder::new() - .unstable_flag("config-include") - .config_arg("missing.toml") - .build_err(); - assert_error( - config.unwrap_err(), - "\ -failed to parse value from --config argument `missing.toml` as a dotted key expression - -Caused by: - TOML parse error at line 1, column 13 - | -1 | missing.toml - | ^ -Unexpected end of input -Expected `.` or `=` -", - ); -}