Skip to content

Commit 3bdb4be

Browse files
committed
fix: gptscriptBin can be relative to where the SDK is running
Signed-off-by: Donnie Adams <[email protected]>
1 parent 5a5c1d9 commit 3bdb4be

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

exec.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import (
66
"encoding/json"
77
"fmt"
88
"io"
9+
"log/slog"
910
"os"
1011
"os/exec"
12+
"path/filepath"
1113
"strings"
1214
)
1315

@@ -312,7 +314,16 @@ func concatTools(tools []fmt.Stringer) string {
312314

313315
func getCommand() string {
314316
if gptScriptBin := os.Getenv("GPTSCRIPT_BIN"); gptScriptBin != "" {
315-
return gptScriptBin
317+
if filepath.IsAbs(gptScriptBin) {
318+
return gptScriptBin
319+
}
320+
cwd, err := os.Getwd()
321+
if err != nil {
322+
slog.Warn("failed to get cwd", "err", err.Error())
323+
return gptScriptBin
324+
}
325+
326+
return filepath.Join(cwd, gptScriptBin)
316327
}
317328

318329
return "gptscript"

0 commit comments

Comments
 (0)