From 5b3653c93622f3ef2ed5d3d31a2cc1622d6afe9c Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Sat, 14 Jan 2023 10:47:23 +0100 Subject: [PATCH] Only remove RUSTUP_TOOLCHAIN env var in xtask build-ebpf --- xtask/src/build_ebpf.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index fa8d1c4..452cb17 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, env, path::PathBuf, process::Command}; +use std::{path::PathBuf, process::Command}; use clap::Parser; @@ -54,16 +54,12 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { } // Command::new creates a child process which inherits all env variables. This means env - // vars set by the cargo xtask command are also inherited. All env vars related to the - // cargo xtask invocation are removed. - let filtered_env: HashMap = env::vars() - .filter(|&(ref k, _)| !k.starts_with("CARGO") && !k.starts_with("RUST")) - .collect(); + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. let status = Command::new("cargo") .current_dir(dir) - .env_clear() - .envs(&filtered_env) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program");