Skip to content

Commit 488be1d

Browse files
hhfrancoisclaude
andcommitted
Fix Windows: resolve agent command path before setting workdir
On Windows, exec.Command resolves executables relative to cmd.Dir instead of searching PATH. Use exec.LookPath to get the absolute path before creating the PTY command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 111183b commit 488be1d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"log"
88
"os"
9+
"os/exec"
910
"os/signal"
1011
"path/filepath"
1112
"runtime"
@@ -281,11 +282,19 @@ func displayHeader(daemon *Daemon, session, command, workDir, agentVersion strin
281282
// startPTY starts the PTY and returns the pty master and command
282283
func startPTY(command, workDir string) (pty.Pty, *pty.Cmd) {
283284
fmt.Printf("Starting %s...\n", command)
285+
286+
// Resolve full path before setting cmd.Dir, otherwise on Windows
287+
// exec.Command resolves the command relative to cmd.Dir instead of PATH
288+
commandPath, err := exec.LookPath(command)
289+
if err != nil {
290+
log.Fatalf("Failed to find '%s' in PATH: %v", command, err)
291+
}
292+
284293
ptmx, err := pty.New()
285294
if err != nil {
286295
log.Fatal("Failed to create PTY:", err)
287296
}
288-
cmd := ptmx.Command(command)
297+
cmd := ptmx.Command(commandPath)
289298
cmd.Dir = workDir
290299
cmd.Env = append(os.Environ(), "TERM=xterm-256color")
291300

0 commit comments

Comments
 (0)