diff --git a/xtask/src/cargo.rs b/xtask/src/cargo.rs index 6ee5943ae..06fbe8a64 100644 --- a/xtask/src/cargo.rs +++ b/xtask/src/cargo.rs @@ -101,6 +101,12 @@ impl Cargo { pub fn command(&self) -> Result { let mut cmd = Command::new("cargo"); + // Cargo automatically sets some env vars that can prevent the + // channel arg (e.g. "+nightly") from working. Unset them in the + // child's environment. + cmd.env_remove("RUSTC"); + cmd.env_remove("RUSTDOC"); + if let Some(toolchain) = &self.toolchain { cmd.arg(&format!("+{}", toolchain)); } @@ -206,7 +212,7 @@ mod tests { }; assert_eq!( command_to_string(&cargo.command().unwrap()), - "RUSTDOCFLAGS=-Dwarnings cargo +nightly doc --package uefi --package xtask --features alloc --open" + "RUSTC= RUSTDOC= RUSTDOCFLAGS=-Dwarnings cargo +nightly doc --package uefi --package xtask --features alloc --open" ); } } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1ecfac7bc..8f661c6b8 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -173,19 +173,28 @@ fn test_latest_release() -> Result<()> { // it explicit that it matches the command in `BUILDING.md`. let mut build_cmd = Command::new("cargo"); build_cmd + .env_remove("RUSTC") .args(&["+nightly", "build", "--target", "x86_64-unknown-uefi"]) .current_dir(tmp_dir.join("template")); // Check that the command is indeed in BUILDING.md, then verify the // build succeeds. let building_md = include_str!("../../BUILDING.md"); - assert!(building_md.contains(&command_to_string(&build_cmd))); + let cmd_str = command_to_string(&build_cmd).replace("RUSTC= ", ""); + assert!(building_md.contains(&cmd_str)); run_cmd(build_cmd) } fn main() -> Result<()> { let opt = Opt::parse(); + // TODO: + println!("=======VARS======="); + for (k, v) in std::env::vars() { + println!("{}={}", k, v); + } + println!("=======VARS======="); + match &opt.action { Action::Build(build_opt) => build(build_opt), Action::Clippy(clippy_opt) => clippy(clippy_opt),