From de7917e29cf5299b5158cb01354289ffd5968edd Mon Sep 17 00:00:00 2001 From: Yahya Saqban Date: Fri, 22 May 2026 23:52:18 +0300 Subject: [PATCH] fix(sensing-server): resolve UI path relative to executable location The sensing-server uses a relative default --ui-path that breaks when not running from the repo root. This adds exe-relative fallback paths so the server finds the UI directory even when launched from an arbitrary CWD. Also adds a clearer warning when no fallback is found. Fixes #188 --- .../wifi-densepose-sensing-server/src/main.rs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/v2/crates/wifi-densepose-sensing-server/src/main.rs b/v2/crates/wifi-densepose-sensing-server/src/main.rs index 681ef6fb..ea9d7533 100644 --- a/v2/crates/wifi-densepose-sensing-server/src/main.rs +++ b/v2/crates/wifi-densepose-sensing-server/src/main.rs @@ -4578,17 +4578,36 @@ fn coalesce_ui_path(initial: std::path::PathBuf) -> std::path::PathBuf { if initial.is_dir() { return initial; } - for rel in &["../ui", "./ui", "../../ui"] { - let p = std::path::PathBuf::from(rel); + // Try relative to CWD + let mut candidates: Vec = vec![ + std::path::PathBuf::from("../ui"), + std::path::PathBuf::from("./ui"), + std::path::PathBuf::from("../../ui"), + ]; + + // Try relative to executable (handles cases where CWD != repo root) + if let Ok(exe) = std::env::current_exe() { + if let Some(exe_dir) = exe.parent() { + candidates.push(exe_dir.join("../ui")); + candidates.push(exe_dir.join("../../ui")); + } + } + + for p in &candidates { if p.is_dir() { warn!( "UI path {} not found; using {} (set --ui-path explicitly if wrong)", initial.display(), p.display() ); - return p; + return p.clone(); } } + + warn!( + "UI path {} not found. Try running from repo root or set --ui-path explicitly.", + initial.display() + ); initial }