Skip to content

Commit 15db3ff

Browse files
authored
Merge pull request #196 from prefrontalsys/fix/macos-gh-path-resolution
Fix: resolve gh CLI path for macOS GUI apps
2 parents e04b5a7 + f6b9859 commit 15db3ff

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)