Only remove RUSTUP_TOOLCHAIN env var in xtask build-ebpf

pull/70/head
arctic-alpaca 2 years ago
parent 039c07f7a2
commit 5b3653c936
No known key found for this signature in database
GPG Key ID: F911E2A7F537230E

@ -1,4 +1,4 @@
use std::{collections::HashMap, env, path::PathBuf, process::Command}; use std::{path::PathBuf, process::Command};
use clap::Parser; 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 // 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 // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// cargo xtask invocation are removed. // so the rust-toolchain.toml file in the -ebpf folder is honored.
let filtered_env: HashMap<String, String> = env::vars()
.filter(|&(ref k, _)| !k.starts_with("CARGO") && !k.starts_with("RUST"))
.collect();
let status = Command::new("cargo") let status = Command::new("cargo")
.current_dir(dir) .current_dir(dir)
.env_clear() .env_remove("RUSTUP_TOOLCHAIN")
.envs(&filtered_env)
.args(&args) .args(&args)
.status() .status()
.expect("failed to build bpf program"); .expect("failed to build bpf program");

Loading…
Cancel
Save