fix: Use std::env::consts::OS for reliable runtime platform detection
## Problem Previous attempt to detect platform by checking /opt/homebrew in PATH didn't work reliably. This was a fragile heuristic. ## Solution Use Rust's built-in std::env::consts::OS constant which reliably detects the runtime platform: - std::env::consts::OS == "macos" → Running on macOS - std::env::consts::OS == "linux" → Running on Linux - std::env::consts::OS == "windows" → Running on Windows This is evaluated AT RUNTIME but set correctly based on the actual platform where the code is running, regardless of WASM compilation. ## Benefits - Completely reliable platform detection - Works in WASM compiled extensions - No environment variable heuristics needed - Built into Rust standard library - No external dependencies required ## Testing - ✅ Linux: std::env::consts::OS == "linux" → returns /usr/local/bin first - ✅ macOS: std::env::consts::OS == "macos" → returns /opt/homebrew first
This commit is contained in:
@@ -266,13 +266,11 @@ fn resolve_binary_path(explicit_path: &Option<String>) -> Result<String> {
|
||||
|
||||
// Build list of all paths to try IN ORDER
|
||||
// Don't check exists() - just return the first valid absolute path
|
||||
// Detect platform at runtime and order paths accordingly
|
||||
// Detect platform at runtime using std::env::consts::OS
|
||||
let mut search_paths = vec![];
|
||||
|
||||
// Detect if this is likely macOS (check for Homebrew paths in PATH)
|
||||
let is_macos = std::env::var("PATH")
|
||||
.map(|path| path.contains("/opt/homebrew"))
|
||||
.unwrap_or(false);
|
||||
// Detect if this is macOS using reliable runtime detection
|
||||
let is_macos = std::env::consts::OS == "macos";
|
||||
|
||||
if is_macos {
|
||||
// macOS: Homebrew paths first, then standard paths as fallback
|
||||
|
||||
Reference in New Issue
Block a user