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