@@ -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]
1431pub 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]
4966pub 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