@@ -31,6 +31,27 @@ pub unsafe fn fork_exec_with_gid(
3131 }
3232 }
3333
34+ // Ensure PATH includes standard locations for commands
35+ // This is especially important in CI environments where sudo might restrict PATH
36+ let current_path = std:: env:: var ( "PATH" ) . unwrap_or_default ( ) ;
37+ let final_path = if !current_path. is_empty ( ) {
38+ // Add standard macOS command locations if not already present
39+ let standard_paths = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ;
40+ if current_path. contains ( "/usr/bin" ) {
41+ current_path
42+ } else {
43+ format ! ( "{}:{}" , current_path, standard_paths)
44+ }
45+ } else {
46+ // No PATH set, use standard macOS paths
47+ "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" . to_string ( )
48+ } ;
49+
50+ debug ! ( "Setting PATH for fork_exec: {}" , final_path) ;
51+ unsafe {
52+ std:: env:: set_var ( "PATH" , final_path) ;
53+ }
54+
3455 // Fork the process
3556 let pid = unsafe { libc:: fork ( ) } ;
3657 if pid < 0 {
@@ -103,7 +124,11 @@ unsafe fn child_process(
103124 }
104125
105126 // If we get here, exec failed
106- debug ! ( "execvp failed: {}" , std:: io:: Error :: last_os_error( ) ) ;
127+ let err = std:: io:: Error :: last_os_error ( ) ;
128+ // Try to get the program name for better debugging
129+ let prog_name = unsafe { std:: ffi:: CStr :: from_ptr ( prog) } . to_string_lossy ( ) ;
130+ eprintln ! ( "execvp failed for '{}': {}" , prog_name, err) ;
131+ debug ! ( "execvp failed for '{}': {}" , prog_name, err) ;
107132 unsafe {
108133 libc:: _exit ( 127 ) ;
109134 }
0 commit comments