From a702adf1d1b96e52a15062dda2b40284fec96802 Mon Sep 17 00:00:00 2001 From: Milan Vukov Date: Wed, 4 Dec 2024 18:17:04 +0100 Subject: [PATCH] Pass HOME env var when fetching version (#2698) Fixes https://github.com/bazelbuild/rules_rust/issues/2662. So, in a github action https://github.com/mvukov/rules_ros2/blob/980afb82f4af92480815e723b47a0cde4bea63a7/.github/workflows/main.yml I use my custom build image https://github.com/mvukov/bazel_builder/blob/49178bdf9c151b1fdb1fb0bac580da5d53a990fd/Dockerfile, no user defined. The github action passes user and HOME folder. The home folder seems to be `/github/home` and fetching the version seems to have problems with this. Therefore, I just pass the HOME env var here. --- crate_universe/src/lockfile.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crate_universe/src/lockfile.rs b/crate_universe/src/lockfile.rs index 2138753420..eb5ca824e5 100644 --- a/crate_universe/src/lockfile.rs +++ b/crate_universe/src/lockfile.rs @@ -159,7 +159,11 @@ impl Digest { } pub(crate) fn bin_version(binary: &Path) -> Result { - let safe_vars = [OsStr::new("HOMEDRIVE"), OsStr::new("PATHEXT")]; + let safe_vars = [ + OsStr::new("HOME"), + OsStr::new("HOMEDRIVE"), + OsStr::new("PATHEXT"), + ]; let env = std::env::vars_os().filter(|(var, _)| safe_vars.contains(&var.as_os_str())); let output = Command::new(binary)