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
This commit is contained in:
parent
4b8d1f2001
commit
de7917e29c
|
|
@ -4578,17 +4578,36 @@ fn coalesce_ui_path(initial: std::path::PathBuf) -> std::path::PathBuf {
|
||||||
if initial.is_dir() {
|
if initial.is_dir() {
|
||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
for rel in &["../ui", "./ui", "../../ui"] {
|
// Try relative to CWD
|
||||||
let p = std::path::PathBuf::from(rel);
|
let mut candidates: Vec<std::path::PathBuf> = 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() {
|
if p.is_dir() {
|
||||||
warn!(
|
warn!(
|
||||||
"UI path {} not found; using {} (set --ui-path explicitly if wrong)",
|
"UI path {} not found; using {} (set --ui-path explicitly if wrong)",
|
||||||
initial.display(),
|
initial.display(),
|
||||||
p.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
|
initial
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue