From 834ef6dcbc2017ab57818b1cf440b90973a2b002 Mon Sep 17 00:00:00 2001 From: Rodrigo Pimentel Date: Tue, 31 Mar 2026 17:44:11 -0300 Subject: [PATCH] Fix berglas exec on Windows by replacing syscall.Exec with os/exec syscall.Exec (execve) does not exist on Windows, causing berglas exec to fail with "not supported by windows" on all Windows builds. Replace syscall.Exec with os/exec.Command which is cross-platform and works on Linux, macOS, and Windows. The child process exit code is propagated to the caller. --- main.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 0b5d7ec..76d7a44 100644 --- a/main.go +++ b/main.go @@ -903,15 +903,16 @@ func execRun(cmd *cobra.Command, args []string) error { env[i] = fmt.Sprintf("%s=%s", k, s) } - execCmdFull, err := exec.LookPath(execCmd) - if err != nil { - return fmt.Errorf("failed to lookup path for %q: %w", execCmd, err) - } - - // Unlike os/exec, execv(3) expects the arguments to include the command. - execArgs = append([]string{execCmdFull}, execArgs...) - - if err := syscall.Exec(execCmdFull, execArgs, env); err != nil { + c := exec.Command(execCmd, execArgs...) + c.Env = env + c.Stdin = os.Stdin + c.Stdout = os.Stdout + c.Stderr = os.Stderr + + if err := c.Run(); err != nil { + if exitErr, ok := err.(*exec.ExitError); ok { + os.Exit(exitErr.ExitCode()) + } return fmt.Errorf("failed to execute %q: %w", execCmd, err) } return nil