From 096cb645045bc0f9916d3b029f4fced27dd3fa88 Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 8 May 2026 22:00:54 +0800 Subject: [PATCH] fix(tools): find gh across common install paths ## Summary - Probe common Linux and macOS gh CLI paths when DEEPSEEK_GH_BIN is not set. - Keep the existing /opt/homebrew/bin/gh fallback for compatibility. - Improve the not-installed error message. ## Verification - GitHub CI passed: lint, version drift, ubuntu/macos/windows tests, npm wrapper smoke, GitGuardian. --- crates/tui/src/tools/github.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/tui/src/tools/github.rs b/crates/tui/src/tools/github.rs index 67ef600d..86444642 100644 --- a/crates/tui/src/tools/github.rs +++ b/crates/tui/src/tools/github.rs @@ -15,6 +15,12 @@ use crate::tools::spec::{ }; const DEFAULT_GH: &str = "/opt/homebrew/bin/gh"; +const FALLBACK_GH_PATHS: &[&str] = &[ + "/usr/bin/gh", // Linux system package manager + "/usr/local/bin/gh", // macOS Intel Homebrew / manual install + "/home/linuxbrew/.linuxbrew/bin/gh", // Linux Homebrew (official prefix) + "/opt/homebrew/bin/gh", // macOS Apple Silicon Homebrew +]; const BODY_ARTIFACT_THRESHOLD: usize = 4_000; const DIFF_ARTIFACT_THRESHOLD: usize = 8_000; @@ -300,7 +306,15 @@ impl ToolSpec for GithubCloseIssueTool { } fn gh_bin() -> String { - std::env::var("DEEPSEEK_GH_BIN").unwrap_or_else(|_| DEFAULT_GH.to_string()) + if let Ok(bin) = std::env::var("DEEPSEEK_GH_BIN") { + return bin; + } + for path in FALLBACK_GH_PATHS { + if std::path::Path::new(path).is_file() { + return path.to_string(); + } + } + DEFAULT_GH.to_string() } fn run_gh_text(context: &ToolContext, args: &[&str]) -> Result { @@ -310,7 +324,7 @@ fn run_gh_text(context: &ToolContext, args: &[&str]) -> Result