lean_ctx/core/
portable_binary.rs1pub fn resolve_portable_binary() -> String {
2 let which_cmd = if cfg!(windows) { "where" } else { "which" };
3 if let Ok(output) = std::process::Command::new(which_cmd)
4 .arg("lean-ctx")
5 .stderr(std::process::Stdio::null())
6 .output()
7 {
8 if output.status.success() {
9 let path = String::from_utf8_lossy(&output.stdout).trim().to_string();
10 if !path.is_empty() {
11 return sanitize_exe_path(path);
12 }
13 }
14 }
15 let path = std::env::current_exe()
16 .map(|p| p.to_string_lossy().to_string())
17 .unwrap_or_else(|_| "lean-ctx".to_string());
18 sanitize_exe_path(path)
19}
20
21fn sanitize_exe_path(path: String) -> String {
22 path.trim_end_matches(" (deleted)").to_string()
23}