From 94f34f3a43eb586ce0a0c14187ec37ac8ce266d0 Mon Sep 17 00:00:00 2001 From: Ryan Parmeter Date: Mon, 10 Nov 2025 20:50:49 -0700 Subject: [PATCH] debug: Add extensive logging to binary path resolution Added eprintln debug statements to trace: - PATH environment variable contents - Each directory being considered - Priority assigned to each path - All candidates after sorting - Final selected path This will help diagnose why Homebrew paths aren't being selected on macOS M4. Debug output goes to stderr which Zed captures in logs. --- src/mcp_server_gitea.rs | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/mcp_server_gitea.rs b/src/mcp_server_gitea.rs index a079868..d3db507 100644 --- a/src/mcp_server_gitea.rs +++ b/src/mcp_server_gitea.rs @@ -284,6 +284,10 @@ fn resolve_binary_path(explicit_path: &Option) -> Result { // Collect all candidate paths from PATH, then prioritize them let mut candidates = Vec::new(); + // DEBUG: Log PATH directories being considered + eprintln!("[TENDRIL DEBUG] PATH environment variable: {}", path_env); + eprintln!("[TENDRIL DEBUG] Searching for binaries: {:?}", binary_names); + // Parse PATH and collect all plausible paths for path_dir in path_env.split(':') { for binary_name in &binary_names { @@ -291,16 +295,37 @@ fn resolve_binary_path(explicit_path: &Option) -> Result { // Categorize by priority (lower number = higher priority) let priority = if path_dir.contains("/opt/homebrew/bin") { + eprintln!( + "[TENDRIL DEBUG] Found Homebrew path (priority 1): {}", + full_path + ); 1 // Highest: macOS Homebrew (M1/M2/M3/M4 Macs) } else if path_dir.contains("/.local/bin") { + eprintln!( + "[TENDRIL DEBUG] Found .local path (priority 2): {}", + full_path + ); 2 // User-local installations } else if path_dir.contains("/.cargo/bin") { + eprintln!( + "[TENDRIL DEBUG] Found .cargo path (priority 3): {}", + full_path + ); 3 // Cargo installations } else if path_dir.contains("/usr/local/bin") { + eprintln!( + "[TENDRIL DEBUG] Found /usr/local path (priority 4): {}", + full_path + ); 4 // Linux standard location } else if path_dir.contains("/usr/bin") { + eprintln!( + "[TENDRIL DEBUG] Found /usr/bin path (priority 5): {}", + full_path + ); 5 // System binaries } else { + eprintln!("[TENDRIL DEBUG] Skipping non-standard path: {}", path_dir); continue; // Skip non-standard locations }; @@ -310,9 +335,22 @@ fn resolve_binary_path(explicit_path: &Option) -> Result { // Sort by priority and return the highest priority candidate candidates.sort_by_key(|(priority, _)| *priority); - if let Some((_, path)) = candidates.first() { + eprintln!( + "[TENDRIL DEBUG] All candidates after sorting: {:?}", + candidates + ); + + if let Some((priority, path)) = candidates.first() { + eprintln!( + "[TENDRIL DEBUG] Selected path (priority {}): {}", + priority, path + ); return Ok(path.clone()); + } else { + eprintln!("[TENDRIL DEBUG] No candidates found in PATH"); } + } else { + eprintln!("[TENDRIL DEBUG] PATH environment variable not found"); } // Fallback: Try common absolute paths