Skip to content

Commit f6b9859

Browse files
prefrontalsysclaude
andcommitted
Fix: resolve gh CLI path for macOS GUI apps
macOS GUI apps launched from Finder/Spotlight inherit a minimal PATH (/usr/bin:/bin:/usr/sbin:/sbin) that excludes Homebrew directories. This causes `Command::new("gh")` to fail with NotFound, showing "gh CLI not installed" even when gh is installed and working from the terminal. Add `find_gh()` helper that checks common Homebrew install locations (/opt/homebrew/bin/gh, /usr/local/bin/gh) before falling back to bare `gh` for PATH-based resolution. Fixes #194 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 14c9600 commit f6b9859

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src-tauri/src/commands/cloud_sync.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,29 @@ use tauri::State;
99

1010
// ─── Authentication ─────────────────────────────────────────────────────────
1111

12+
/// Resolve the `gh` binary path.
13+
///
14+
/// macOS GUI apps inherit a minimal PATH that excludes Homebrew directories.
15+
/// This checks common install locations before falling back to bare `gh`.
16+
fn find_gh() -> std::path::PathBuf {
17+
for candidate in &[
18+
"/opt/homebrew/bin/gh", // Homebrew on Apple Silicon
19+
"/usr/local/bin/gh", // Homebrew on Intel / manual install
20+
"/usr/bin/gh", // System install
21+
] {
22+
if std::path::Path::new(candidate).exists() {
23+
return candidate.into();
24+
}
25+
}
26+
"gh".into()
27+
}
28+
1229
/// Get a GitHub token from the gh CLI
1330
#[tauri::command]
1431
pub async fn get_gh_cli_token() -> Result<String, String> {
1532
info!("[CloudSync] Getting token from gh CLI");
1633
tokio::task::spawn_blocking(|| {
17-
let output = std::process::Command::new("gh")
34+
let output = std::process::Command::new(find_gh())
1835
.args(["auth", "token"])
1936
.output()
2037
.map_err(|e| {
@@ -47,7 +64,7 @@ pub async fn get_gh_cli_token() -> Result<String, String> {
4764
/// Check if gh CLI is installed
4865
#[tauri::command]
4966
pub fn has_gh_cli() -> bool {
50-
std::process::Command::new("gh")
67+
std::process::Command::new(find_gh())
5168
.arg("--version")
5269
.output()
5370
.map(|o| o.status.success())

0 commit comments

Comments
 (0)