diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 3053854d4c7..99b0ccef21e 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -1,4 +1,4 @@ -use anyhow::anyhow; +use anyhow::{anyhow, Context as _}; use cargo::core::shell::Shell; use cargo::core::{features, CliUnstable}; use cargo::{self, drop_print, drop_println, CliResult, Config}; @@ -27,6 +27,13 @@ lazy_static::lazy_static! { pub fn main(config: &mut LazyConfig) -> CliResult { let args = cli().try_get_matches()?; + // Update the process-level notion of cwd + // This must be completed before config is initialized + assert_eq!(config.is_init(), false); + if let Some(new_cwd) = args.get_one::("directory") { + std::env::set_current_dir(&new_cwd).context("could not change to requested directory")?; + } + // CAUTION: Be careful with using `config` until it is configured below. // In general, try to avoid loading config values unless necessary (like // the [alias] table). @@ -467,6 +474,14 @@ See 'cargo help ' for more information on a specific command.\n", .value_name("WHEN") .global(true), ) + .arg( + Arg::new("directory") + .help("Change to DIRECTORY before doing anything") + .short('C') + .value_name("DIRECTORY") + .value_hint(clap::ValueHint::DirPath) + .value_parser(clap::builder::ValueParser::path_buf()), + ) .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)) @@ -497,6 +512,13 @@ impl LazyConfig { Self { config: None } } + /// Check whether the config is loaded + /// + /// This is useful for asserts in case the environment needs to be setup before loading + pub fn is_init(&self) -> bool { + self.config.is_some() + } + /// Get the config, loading it if needed /// /// On error, the process is terminated diff --git a/src/doc/man/generated_txt/cargo-add.txt b/src/doc/man/generated_txt/cargo-add.txt index 832d66a82db..e97ef57540d 100644 --- a/src/doc/man/generated_txt/cargo-add.txt +++ b/src/doc/man/generated_txt/cargo-add.txt @@ -185,6 +185,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 09d67668c63..5e833272d15 100644 --- a/src/doc/man/generated_txt/cargo-bench.txt +++ b/src/doc/man/generated_txt/cargo-bench.txt @@ -363,6 +363,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 803a438eb8d..aae7e94ada0 100644 --- a/src/doc/man/generated_txt/cargo-build.txt +++ b/src/doc/man/generated_txt/cargo-build.txt @@ -312,6 +312,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 2af4fe06f3b..069f316492b 100644 --- a/src/doc/man/generated_txt/cargo-check.txt +++ b/src/doc/man/generated_txt/cargo-check.txt @@ -297,6 +297,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 ef8952df58f..93e4ee24ad7 100644 --- a/src/doc/man/generated_txt/cargo-clean.txt +++ b/src/doc/man/generated_txt/cargo-clean.txt @@ -127,6 +127,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 abfe484a110..26ce1aa3934 100644 --- a/src/doc/man/generated_txt/cargo-doc.txt +++ b/src/doc/man/generated_txt/cargo-doc.txt @@ -268,6 +268,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 1598dc9d837..5cc454d0b38 100644 --- a/src/doc/man/generated_txt/cargo-fetch.txt +++ b/src/doc/man/generated_txt/cargo-fetch.txt @@ -112,6 +112,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 7f1b05b429e..878b6aa9b75 100644 --- a/src/doc/man/generated_txt/cargo-fix.txt +++ b/src/doc/man/generated_txt/cargo-fix.txt @@ -370,6 +370,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 6c742093281..892b3df2e3f 100644 --- a/src/doc/man/generated_txt/cargo-generate-lockfile.txt +++ b/src/doc/man/generated_txt/cargo-generate-lockfile.txt @@ -87,6 +87,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 92d0f0c5f1e..1071627f8d2 100644 --- a/src/doc/man/generated_txt/cargo-init.txt +++ b/src/doc/man/generated_txt/cargo-init.txt @@ -95,6 +95,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 6a92526d096..0ed871e3cbe 100644 --- a/src/doc/man/generated_txt/cargo-install.txt +++ b/src/doc/man/generated_txt/cargo-install.txt @@ -334,6 +334,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 4b7a3759d4b..bc1ab6cd32f 100644 --- a/src/doc/man/generated_txt/cargo-locate-project.txt +++ b/src/doc/man/generated_txt/cargo-locate-project.txt @@ -77,6 +77,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 66238fb5a65..b6dcbc1d79c 100644 --- a/src/doc/man/generated_txt/cargo-login.txt +++ b/src/doc/man/generated_txt/cargo-login.txt @@ -70,6 +70,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 1bb33b4f2c0..c67757cd30d 100644 --- a/src/doc/man/generated_txt/cargo-metadata.txt +++ b/src/doc/man/generated_txt/cargo-metadata.txt @@ -400,6 +400,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 7b429e347d6..30f610ed6f2 100644 --- a/src/doc/man/generated_txt/cargo-new.txt +++ b/src/doc/man/generated_txt/cargo-new.txt @@ -90,6 +90,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 dd1c017ab87..6e98506ccf7 100644 --- a/src/doc/man/generated_txt/cargo-owner.txt +++ b/src/doc/man/generated_txt/cargo-owner.txt @@ -97,6 +97,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 162c196d0c5..2c23883ffcd 100644 --- a/src/doc/man/generated_txt/cargo-package.txt +++ b/src/doc/man/generated_txt/cargo-package.txt @@ -238,6 +238,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 e2c3cbd99b6..e94a04d327b 100644 --- a/src/doc/man/generated_txt/cargo-pkgid.txt +++ b/src/doc/man/generated_txt/cargo-pkgid.txt @@ -117,6 +117,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 29ebfcdcecb..7e12c724630 100644 --- a/src/doc/man/generated_txt/cargo-publish.txt +++ b/src/doc/man/generated_txt/cargo-publish.txt @@ -205,6 +205,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo-remove.txt b/src/doc/man/generated_txt/cargo-remove.txt index c11992e7f7c..f206c523e5e 100644 --- a/src/doc/man/generated_txt/cargo-remove.txt +++ b/src/doc/man/generated_txt/cargo-remove.txt @@ -103,6 +103,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 6ef1e46a610..09f445e994a 100644 --- a/src/doc/man/generated_txt/cargo-run.txt +++ b/src/doc/man/generated_txt/cargo-run.txt @@ -212,6 +212,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 45c402e2c34..38da4a3de86 100644 --- a/src/doc/man/generated_txt/cargo-rustc.txt +++ b/src/doc/man/generated_txt/cargo-rustc.txt @@ -314,6 +314,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 69ef35e50f7..a3218916b5e 100644 --- a/src/doc/man/generated_txt/cargo-rustdoc.txt +++ b/src/doc/man/generated_txt/cargo-rustdoc.txt @@ -284,6 +284,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 240adf02d6d..d0531de9159 100644 --- a/src/doc/man/generated_txt/cargo-search.txt +++ b/src/doc/man/generated_txt/cargo-search.txt @@ -67,6 +67,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 0872c9b1c4b..653f1d6f1a0 100644 --- a/src/doc/man/generated_txt/cargo-test.txt +++ b/src/doc/man/generated_txt/cargo-test.txt @@ -381,6 +381,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 ee85eaf261d..e41d23e7e01 100644 --- a/src/doc/man/generated_txt/cargo-tree.txt +++ b/src/doc/man/generated_txt/cargo-tree.txt @@ -298,6 +298,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 c14c01a65d0..19ac378a02b 100644 --- a/src/doc/man/generated_txt/cargo-uninstall.txt +++ b/src/doc/man/generated_txt/cargo-uninstall.txt @@ -79,6 +79,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 5b7a072255e..a9c1b934e40 100644 --- a/src/doc/man/generated_txt/cargo-update.txt +++ b/src/doc/man/generated_txt/cargo-update.txt @@ -117,6 +117,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 a466a7f9d98..e2f07f5fa2b 100644 --- a/src/doc/man/generated_txt/cargo-vendor.txt +++ b/src/doc/man/generated_txt/cargo-vendor.txt @@ -113,6 +113,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 23d8842bd0b..b98c076f47d 100644 --- a/src/doc/man/generated_txt/cargo-verify-project.txt +++ b/src/doc/man/generated_txt/cargo-verify-project.txt @@ -90,6 +90,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 e844f06bcb6..23dd9138961 100644 --- a/src/doc/man/generated_txt/cargo-yank.txt +++ b/src/doc/man/generated_txt/cargo-yank.txt @@ -93,6 +93,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -h, --help Prints help information. diff --git a/src/doc/man/generated_txt/cargo.txt b/src/doc/man/generated_txt/cargo.txt index c8072e68700..f2d4a9f6ad2 100644 --- a/src/doc/man/generated_txt/cargo.txt +++ b/src/doc/man/generated_txt/cargo.txt @@ -196,6 +196,12 @@ OPTIONS for more information. + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. + -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 83b44fd83ed..db09f977fd0 100644 --- a/src/doc/man/includes/section-options-common.md +++ b/src/doc/man/includes/section-options-common.md @@ -16,6 +16,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the [command-line overrides section](../reference/config.html#command-line-overrides) for more information. {{/option}} +{{#option "`-C` _PATH_"}} +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (`Cargo.toml`), as well as +the directories searched for discovering `.cargo/config.toml`, for example. +{{/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 3655384de8f..13c2ab423ab 100644 --- a/src/doc/src/commands/cargo-add.md +++ b/src/doc/src/commands/cargo-add.md @@ -222,6 +222,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md index b0ecf2159b7..06b3b9923f4 100644 --- a/src/doc/src/commands/cargo-bench.md +++ b/src/doc/src/commands/cargo-bench.md @@ -427,6 +427,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-build.md b/src/doc/src/commands/cargo-build.md index 5e1fdd039a4..971b0f4a216 100644 --- a/src/doc/src/commands/cargo-build.md +++ b/src/doc/src/commands/cargo-build.md @@ -371,6 +371,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-check.md b/src/doc/src/commands/cargo-check.md index 82ba76ee39f..730e10d0629 100644 --- a/src/doc/src/commands/cargo-check.md +++ b/src/doc/src/commands/cargo-check.md @@ -352,6 +352,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-clean.md b/src/doc/src/commands/cargo-clean.md index c7cd8fe5274..89132f7d5ad 100644 --- a/src/doc/src/commands/cargo-clean.md +++ b/src/doc/src/commands/cargo-clean.md @@ -156,6 +156,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-doc.md b/src/doc/src/commands/cargo-doc.md index 9258705b748..2c6af666d35 100644 --- a/src/doc/src/commands/cargo-doc.md +++ b/src/doc/src/commands/cargo-doc.md @@ -326,6 +326,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-fetch.md b/src/doc/src/commands/cargo-fetch.md index 93e8aba3f26..471644fc3f4 100644 --- a/src/doc/src/commands/cargo-fetch.md +++ b/src/doc/src/commands/cargo-fetch.md @@ -130,6 +130,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-fix.md b/src/doc/src/commands/cargo-fix.md index dccffd579ae..db8e7b793c5 100644 --- a/src/doc/src/commands/cargo-fix.md +++ b/src/doc/src/commands/cargo-fix.md @@ -432,6 +432,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-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 9712cf66329..c47f0b1272a 100644 --- a/src/doc/src/commands/cargo-generate-lockfile.md +++ b/src/doc/src/commands/cargo-generate-lockfile.md @@ -104,6 +104,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-init.md b/src/doc/src/commands/cargo-init.md index d2317c399ed..8162cb3b249 100644 --- a/src/doc/src/commands/cargo-init.md +++ b/src/doc/src/commands/cargo-init.md @@ -117,6 +117,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-install.md b/src/doc/src/commands/cargo-install.md index f1450a9333b..1262b79e0cd 100644 --- a/src/doc/src/commands/cargo-install.md +++ b/src/doc/src/commands/cargo-install.md @@ -381,6 +381,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-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 3e42f3f073d..736407ad38f 100644 --- a/src/doc/src/commands/cargo-locate-project.md +++ b/src/doc/src/commands/cargo-locate-project.md @@ -99,6 +99,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-login.md b/src/doc/src/commands/cargo-login.md index 35fab6763d0..d8c1c9e5d3d 100644 --- a/src/doc/src/commands/cargo-login.md +++ b/src/doc/src/commands/cargo-login.md @@ -85,6 +85,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-metadata.md b/src/doc/src/commands/cargo-metadata.md index 4bac638fdaa..51bbda524f6 100644 --- a/src/doc/src/commands/cargo-metadata.md +++ b/src/doc/src/commands/cargo-metadata.md @@ -434,6 +434,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-new.md b/src/doc/src/commands/cargo-new.md index 0f4f8e7f3c3..6bca79594b8 100644 --- a/src/doc/src/commands/cargo-new.md +++ b/src/doc/src/commands/cargo-new.md @@ -112,6 +112,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-owner.md b/src/doc/src/commands/cargo-owner.md index 73df3cd9902..0473790cd99 100644 --- a/src/doc/src/commands/cargo-owner.md +++ b/src/doc/src/commands/cargo-owner.md @@ -123,6 +123,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-package.md b/src/doc/src/commands/cargo-package.md index a58614c6789..efae5db59df 100644 --- a/src/doc/src/commands/cargo-package.md +++ b/src/doc/src/commands/cargo-package.md @@ -289,6 +289,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-pkgid.md b/src/doc/src/commands/cargo-pkgid.md index 873881d8b57..ab6d5134c2b 100644 --- a/src/doc/src/commands/cargo-pkgid.md +++ b/src/doc/src/commands/cargo-pkgid.md @@ -133,6 +133,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-publish.md b/src/doc/src/commands/cargo-publish.md index a308c4dca05..e69d7170eb2 100644 --- a/src/doc/src/commands/cargo-publish.md +++ b/src/doc/src/commands/cargo-publish.md @@ -255,6 +255,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-remove.md b/src/doc/src/commands/cargo-remove.md index 0a0024f5e83..66d01432ef8 100644 --- a/src/doc/src/commands/cargo-remove.md +++ b/src/doc/src/commands/cargo-remove.md @@ -140,6 +140,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-run.md b/src/doc/src/commands/cargo-run.md index 43fcc026b84..530684942c3 100644 --- a/src/doc/src/commands/cargo-run.md +++ b/src/doc/src/commands/cargo-run.md @@ -264,6 +264,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-rustc.md b/src/doc/src/commands/cargo-rustc.md index 606ce778516..d753426bedf 100644 --- a/src/doc/src/commands/cargo-rustc.md +++ b/src/doc/src/commands/cargo-rustc.md @@ -365,6 +365,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-rustdoc.md b/src/doc/src/commands/cargo-rustdoc.md index c8b6ecf97e5..a75d5e2fd4e 100644 --- a/src/doc/src/commands/cargo-rustdoc.md +++ b/src/doc/src/commands/cargo-rustdoc.md @@ -345,6 +345,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-search.md b/src/doc/src/commands/cargo-search.md index 78dfa290f8d..8b509197c86 100644 --- a/src/doc/src/commands/cargo-search.md +++ b/src/doc/src/commands/cargo-search.md @@ -89,6 +89,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-test.md b/src/doc/src/commands/cargo-test.md index 69e9a5ae4e9..9614e259eb1 100644 --- a/src/doc/src/commands/cargo-test.md +++ b/src/doc/src/commands/cargo-test.md @@ -450,6 +450,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-tree.md b/src/doc/src/commands/cargo-tree.md index 9b1fde0eb11..8ce1480e2d5 100644 --- a/src/doc/src/commands/cargo-tree.md +++ b/src/doc/src/commands/cargo-tree.md @@ -336,6 +336,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-uninstall.md b/src/doc/src/commands/cargo-uninstall.md index 5d2561a19c9..5249eedf3fc 100644 --- a/src/doc/src/commands/cargo-uninstall.md +++ b/src/doc/src/commands/cargo-uninstall.md @@ -99,6 +99,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-update.md b/src/doc/src/commands/cargo-update.md index cbea81b3b9a..dad1c4757e7 100644 --- a/src/doc/src/commands/cargo-update.md +++ b/src/doc/src/commands/cargo-update.md @@ -144,6 +144,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-vendor.md b/src/doc/src/commands/cargo-vendor.md index 194107265da..020ddce7c8d 100644 --- a/src/doc/src/commands/cargo-vendor.md +++ b/src/doc/src/commands/cargo-vendor.md @@ -140,6 +140,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-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 2e44fedac21..9d59468d666 100644 --- a/src/doc/src/commands/cargo-verify-project.md +++ b/src/doc/src/commands/cargo-verify-project.md @@ -110,6 +110,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo-yank.md b/src/doc/src/commands/cargo-yank.md index ec68e7ca9f3..f8bac57419f 100644 --- a/src/doc/src/commands/cargo-yank.md +++ b/src/doc/src/commands/cargo-yank.md @@ -119,6 +119,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/doc/src/commands/cargo.md b/src/doc/src/commands/cargo.md index 683133838f8..2329ea021e3 100644 --- a/src/doc/src/commands/cargo.md +++ b/src/doc/src/commands/cargo.md @@ -227,6 +227,12 @@ or provided as a path to an extra configuration file. This flag may be specified See the command-line overrides section for more information. +
-C PATH
+
Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (Cargo.toml), as well as +the directories searched for discovering .cargo/config.toml, for example.
+ +
-h
--help
Prints help information.
diff --git a/src/etc/man/cargo-add.1 b/src/etc/man/cargo-add.1 index b82cb21cc96..51bc190b2c7 100644 --- a/src/etc/man/cargo-add.1 +++ b/src/etc/man/cargo-add.1 @@ -237,6 +237,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1 index 0f04fa3ef18..ee94caa849c 100644 --- a/src/etc/man/cargo-bench.1 +++ b/src/etc/man/cargo-bench.1 @@ -451,6 +451,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1 index 9421f5bf8c7..f2bb188bf74 100644 --- a/src/etc/man/cargo-build.1 +++ b/src/etc/man/cargo-build.1 @@ -381,6 +381,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-check.1 b/src/etc/man/cargo-check.1 index e9a91d362fa..c2da3d3201a 100644 --- a/src/etc/man/cargo-check.1 +++ b/src/etc/man/cargo-check.1 @@ -362,6 +362,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-clean.1 b/src/etc/man/cargo-clean.1 index 9570dd0e7e3..1d945cb9819 100644 --- a/src/etc/man/cargo-clean.1 +++ b/src/etc/man/cargo-clean.1 @@ -155,6 +155,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-doc.1 b/src/etc/man/cargo-doc.1 index 4bad7ec9144..d6757dc65e1 100644 --- a/src/etc/man/cargo-doc.1 +++ b/src/etc/man/cargo-doc.1 @@ -329,6 +329,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-fetch.1 b/src/etc/man/cargo-fetch.1 index 960ee507e4b..bab11829c9c 100644 --- a/src/etc/man/cargo-fetch.1 +++ b/src/etc/man/cargo-fetch.1 @@ -129,6 +129,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-fix.1 b/src/etc/man/cargo-fix.1 index 0e92a8dfcd7..bcc709f900e 100644 --- a/src/etc/man/cargo-fix.1 +++ b/src/etc/man/cargo-fix.1 @@ -457,6 +457,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-generate-lockfile.1 b/src/etc/man/cargo-generate-lockfile.1 index 5ac1d1ca34b..67cf7a8f466 100644 --- a/src/etc/man/cargo-generate-lockfile.1 +++ b/src/etc/man/cargo-generate-lockfile.1 @@ -108,6 +108,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-init.1 b/src/etc/man/cargo-init.1 index 6f4754b5cde..7ec56fb05bc 100644 --- a/src/etc/man/cargo-init.1 +++ b/src/etc/man/cargo-init.1 @@ -121,6 +121,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-install.1 b/src/etc/man/cargo-install.1 index b0b9cbe74a9..ace8371ff37 100644 --- a/src/etc/man/cargo-install.1 +++ b/src/etc/man/cargo-install.1 @@ -433,6 +433,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-locate-project.1 b/src/etc/man/cargo-locate-project.1 index 984a0afea12..3dbb8b6541b 100644 --- a/src/etc/man/cargo-locate-project.1 +++ b/src/etc/man/cargo-locate-project.1 @@ -100,6 +100,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-login.1 b/src/etc/man/cargo-login.1 index 7c197b62f43..b51eebcc7b5 100644 --- a/src/etc/man/cargo-login.1 +++ b/src/etc/man/cargo-login.1 @@ -85,6 +85,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-metadata.1 b/src/etc/man/cargo-metadata.1 index e9b90105546..297cf23260a 100644 --- a/src/etc/man/cargo-metadata.1 +++ b/src/etc/man/cargo-metadata.1 @@ -433,6 +433,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-new.1 b/src/etc/man/cargo-new.1 index 766c11d6ac9..43841001c3c 100644 --- a/src/etc/man/cargo-new.1 +++ b/src/etc/man/cargo-new.1 @@ -116,6 +116,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-owner.1 b/src/etc/man/cargo-owner.1 index 4b9c2bb8fee..5436314dcca 100644 --- a/src/etc/man/cargo-owner.1 +++ b/src/etc/man/cargo-owner.1 @@ -127,6 +127,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-package.1 b/src/etc/man/cargo-package.1 index 2a8d0839645..9ecf4f3f53e 100644 --- a/src/etc/man/cargo-package.1 +++ b/src/etc/man/cargo-package.1 @@ -301,6 +301,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-pkgid.1 b/src/etc/man/cargo-pkgid.1 index 9026dd82441..f836f18dd28 100644 --- a/src/etc/man/cargo-pkgid.1 +++ b/src/etc/man/cargo-pkgid.1 @@ -163,6 +163,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-publish.1 b/src/etc/man/cargo-publish.1 index 1694299bd0d..03809538d4a 100644 --- a/src/etc/man/cargo-publish.1 +++ b/src/etc/man/cargo-publish.1 @@ -251,6 +251,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-remove.1 b/src/etc/man/cargo-remove.1 index 231af39d081..8df7eaa3ec8 100644 --- a/src/etc/man/cargo-remove.1 +++ b/src/etc/man/cargo-remove.1 @@ -132,6 +132,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-run.1 b/src/etc/man/cargo-run.1 index af8b55820f7..45b9817e4ae 100644 --- a/src/etc/man/cargo-run.1 +++ b/src/etc/man/cargo-run.1 @@ -262,6 +262,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-rustc.1 b/src/etc/man/cargo-rustc.1 index 9c2d5afc595..8cc95048246 100644 --- a/src/etc/man/cargo-rustc.1 +++ b/src/etc/man/cargo-rustc.1 @@ -380,6 +380,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1 index cedf3d1db34..4214b7a164f 100644 --- a/src/etc/man/cargo-rustdoc.1 +++ b/src/etc/man/cargo-rustdoc.1 @@ -348,6 +348,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-search.1 b/src/etc/man/cargo-search.1 index 921892370cf..1f1e08b108f 100644 --- a/src/etc/man/cargo-search.1 +++ b/src/etc/man/cargo-search.1 @@ -88,6 +88,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1 index ddf2e47774f..02325858838 100644 --- a/src/etc/man/cargo-test.1 +++ b/src/etc/man/cargo-test.1 @@ -470,6 +470,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-tree.1 b/src/etc/man/cargo-tree.1 index f99484b7580..2103adc6a55 100644 --- a/src/etc/man/cargo-tree.1 +++ b/src/etc/man/cargo-tree.1 @@ -376,6 +376,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-uninstall.1 b/src/etc/man/cargo-uninstall.1 index 6df3d9566da..b6c888f9998 100644 --- a/src/etc/man/cargo-uninstall.1 +++ b/src/etc/man/cargo-uninstall.1 @@ -111,6 +111,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-update.1 b/src/etc/man/cargo-update.1 index 307fe834c71..6ca5c52d987 100644 --- a/src/etc/man/cargo-update.1 +++ b/src/etc/man/cargo-update.1 @@ -148,6 +148,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-vendor.1 b/src/etc/man/cargo-vendor.1 index 75dbbd08e14..d7fb9220b98 100644 --- a/src/etc/man/cargo-vendor.1 +++ b/src/etc/man/cargo-vendor.1 @@ -139,6 +139,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-verify-project.1 b/src/etc/man/cargo-verify-project.1 index 09d6de02164..fe4aa0c8b75 100644 --- a/src/etc/man/cargo-verify-project.1 +++ b/src/etc/man/cargo-verify-project.1 @@ -118,6 +118,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo-yank.1 b/src/etc/man/cargo-yank.1 index 91d87dddbf3..00a795a4a78 100644 --- a/src/etc/man/cargo-yank.1 +++ b/src/etc/man/cargo-yank.1 @@ -119,6 +119,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/src/etc/man/cargo.1 b/src/etc/man/cargo.1 index f95fe9cdb96..571e52f1fc0 100644 --- a/src/etc/man/cargo.1 +++ b/src/etc/man/cargo.1 @@ -251,6 +251,13 @@ or provided as a path to an extra configuration file. This flag may be specified See the \fIcommand\-line overrides section\fR for more information. .RE .sp +\fB\-C\fR \fIPATH\fR +.RS 4 +Changes the current working directory before executing any specified operations. This affects +things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as +the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. +.RE +.sp \fB\-h\fR, \fB\-\-help\fR .RS 4 diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 45eb1f2e0fe..015139a5862 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -159,6 +159,44 @@ fn cargo_compile_manifest_path() { assert!(p.bin("foo").is_file()); } +#[cargo_test] +fn cargo_compile_directory_not_cwd() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .file(".cargo/config.toml", &"") + .build(); + + p.cargo("-C foo build") + .cwd(p.root().parent().unwrap()) + .run(); + assert!(p.bin("foo").is_file()); +} + +#[cargo_test] +fn cargo_compile_directory_not_cwd_with_invalid_config() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .file(".cargo/config.toml", &"!") + .build(); + + p.cargo("-C foo build") + .cwd(p.root().parent().unwrap()) + .with_status(101) + .with_stderr_contains( + "\ +Caused by: + TOML parse error at line 1, column 1 + | + 1 | ! + | ^ + Unexpected `!` + Expected key or end of input", + ) + .run(); +} + #[cargo_test] fn cargo_compile_with_invalid_manifest() { let p = project().file("Cargo.toml", "").build();