diff --git a/pkg/engine/cmd.go b/pkg/engine/cmd.go index af2dffc8..7e318eb9 100644 --- a/pkg/engine/cmd.go +++ b/pkg/engine/cmd.go @@ -8,6 +8,7 @@ import ( "io" "os" "os/exec" + "path/filepath" "runtime" "sort" "strings" @@ -202,6 +203,17 @@ func (e *Engine) newCommand(ctx context.Context, extraEnv []string, tool types.T cmdArgs = append(cmdArgs, f.Name()) } + // This is a workaround for Windows, where the command interpreter is constructed with unix style paths + // It converts unix style paths to windows style paths + if runtime.GOOS == "windows" { + parts := strings.Split(args[0], "/") + if parts[len(parts)-1] == "gptscript-go-tool" { + parts[len(parts)-1] = "gptscript-go-tool.exe" + } + + args[0] = filepath.Join(parts...) + } + cmd := exec.CommandContext(ctx, env.Lookup(envvars, args[0]), cmdArgs...) cmd.Env = envvars return cmd, stop, nil diff --git a/pkg/engine/daemon.go b/pkg/engine/daemon.go index c5863833..0d645a0a 100644 --- a/pkg/engine/daemon.go +++ b/pkg/engine/daemon.go @@ -172,7 +172,7 @@ func (e *Engine) startDaemon(_ context.Context, tool types.Tool) (string, error) e.Ports.daemonWG.Done() }) - for i := 0; i < 20; i++ { + for i := 0; i < 120; i++ { resp, err := http.Get(url) if err == nil && resp.StatusCode == http.StatusOK { go func() { diff --git a/pkg/repos/runtimes/golang/golang.go b/pkg/repos/runtimes/golang/golang.go index 9ea6e14d..0c7a48ac 100644 --- a/pkg/repos/runtimes/golang/golang.go +++ b/pkg/repos/runtimes/golang/golang.go @@ -77,12 +77,19 @@ func stripGo(env []string) (result []string) { func (r *Runtime) runBuild(ctx context.Context, toolSource, binDir string, env []string) error { log.Infof("Running go build in %s", toolSource) - cmd := debugcmd.New(ctx, filepath.Join(binDir, "go"), "build", "-buildvcs=false", "-o", "bin/gptscript-go-tool") + cmd := debugcmd.New(ctx, filepath.Join(binDir, "go"), "build", "-buildvcs=false", "-o", artifactName()) cmd.Env = stripGo(env) cmd.Dir = toolSource return cmd.Run() } +func artifactName() string { + if runtime.GOOS == "windows" { + return filepath.Join("bin", "gptscript-go-tool.exe") + } + return filepath.Join("bin", "gptscript-go-tool") +} + func (r *Runtime) binDir(rel string) string { return filepath.Join(rel, "go", "bin") }