From af4a3ebe636b501423b68c77a0574d337a987037 Mon Sep 17 00:00:00 2001 From: yuanyuyuan Date: Thu, 16 Jul 2026 22:09:55 +0800 Subject: [PATCH] fix(shm): fail loudly if CARGO_CFG_TARGET_OS is unset unwrap_or_default() would silently compute shm_external_lockfile as false on a missing var, misconfiguring BSD/Redox builds with no diagnostic. CARGO_CFG_TARGET_OS is always set by Cargo when running build scripts normally; expect() surfaces a nonstandard invocation immediately instead of masking it. --- commons/zenoh-shm/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commons/zenoh-shm/build.rs b/commons/zenoh-shm/build.rs index 72158ab769..0442d10728 100644 --- a/commons/zenoh-shm/build.rs +++ b/commons/zenoh-shm/build.rs @@ -19,7 +19,8 @@ fn main() { // family (including all Apple targets, which are BSD-derived) plus // Redox. Computed directly instead of pulling in the `cfg_aliases` // crate for a single derived flag. - let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let target_os = std::env::var("CARGO_CFG_TARGET_OS") + .expect("CARGO_CFG_TARGET_OS must be set by Cargo when running build scripts"); let shm_external_lockfile = matches!( target_os.as_str(), "freebsd"