diff --git a/Cargo.lock b/Cargo.lock index ba6d40605d6..23a660a0f93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -563,9 +563,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.29" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" +checksum = "74a01f4f9ee6c066d42a1c8dedf0dcddad16c72a8981a309d6398de3a75b0c39" dependencies = [ "clap", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index 633a5f7fe52..bc86f408610 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ cargo-util = { version = "0.2.14", path = "crates/cargo-util" } cargo-util-schemas = { version = "0.7.0", path = "crates/cargo-util-schemas" } cargo_metadata = "0.18.1" clap = "4.5.18" -clap_complete = { version = "4.5.29", features = ["unstable-dynamic"] } +clap_complete = { version = "4.5.32", features = ["unstable-dynamic"] } color-print = "0.3.6" core-foundation = { version = "0.10.0", features = ["mac_os_10_7_support"] } crates-io = { version = "0.40.4", path = "crates/crates-io" } diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index 269237858cc..fa41e9c3ff4 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -34,8 +34,11 @@ fn main() { let _span = tracing::span!(tracing::Level::TRACE, "completions").entered(); let args = std::env::args_os(); let current_dir = std::env::current_dir().ok(); - let completer = - clap_complete::CompleteEnv::with_factory(|| cli::cli(&mut gctx)).var("CARGO_COMPLETE"); + let completer = clap_complete::CompleteEnv::with_factory(|| { + let mut gctx = GlobalContext::default().expect("already loaded without errors"); + cli::cli(&mut gctx) + }) + .var("CARGO_COMPLETE"); if completer .try_complete(args, current_dir.as_deref()) .unwrap_or_else(|e| {