diff --git a/eden/scm/lib/util/Cargo.toml b/eden/scm/lib/util/Cargo.toml index e60b69549ee7c..47ff42a963048 100644 --- a/eden/scm/lib/util/Cargo.toml +++ b/eden/scm/lib/util/Cargo.toml @@ -25,6 +25,8 @@ sapling-rewrite-macros = { version = "0.1.0", path = "rewrite-macros" } shell-escape = "0.1.5" shellexpand = "2.1.2" thiserror = "2" +tracing = { version = "0.1.40", features = ["attributes", "valuable"] } +whoami = "1.5" [dev-dependencies] memmap2 = "0.5.10" diff --git a/eden/scm/lib/util/src/sys.rs b/eden/scm/lib/util/src/sys.rs index 520761f8c4259..c4e8d89e540bc 100644 --- a/eden/scm/lib/util/src/sys.rs +++ b/eden/scm/lib/util/src/sys.rs @@ -16,15 +16,13 @@ pub fn hostname() -> String { // Also, this may fix some debugruntest issues on mac due to whoami issues. "test-hostname".to_owned() } else { - std::env::var_os(if cfg!(windows) { - "COMPUTERNAME" - } else if cfg!(target_os = "macos") { - "HOST" - } else { - "HOSTNAME" - }) - .and_then(|h| h.to_str().map(|s| s.to_string())) - .unwrap_or("".to_owned()) + match whoami::fallible::hostname() { + Ok(hostname) => hostname, + Err(err) => { + tracing::error!(?err, "error getting hostname"); + "".to_string() + } + } } }