Skip to content

Commit f830707

Browse files
committed
chore: ensure gptscript stack uses the same binary
When starting gptscript in the various modes (CLI, UI, server, etc), the same binary should be used for the whole stack via the GPTSCRIPT_BIN environment variable. This change does exactly that. Signed-off-by: Donnie Adams <[email protected]>
1 parent a2e23a5 commit f830707

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/cli/gptscript.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (r *GPTScript) PersistentPre(*cobra.Command, []string) error {
221221
}
222222
}
223223

224-
_ = os.Setenv("GPTSCRIPT_BIN", system.Bin())
224+
_ = os.Setenv(system.BinEnvVar, system.Bin())
225225

226226
if r.DefaultModel != "" {
227227
builtin.SetDefaultModel(r.DefaultModel)
@@ -344,6 +344,9 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) {
344344
}
345345

346346
gptOpt.Env = append(gptOpt.Env, "SCRIPTS_PATH="+filepath.Dir(absPathToScript))
347+
if os.Getenv(system.BinEnvVar) == "" {
348+
gptOpt.Env = append(gptOpt.Env, system.BinEnvVar+"="+system.Bin())
349+
}
347350

348351
args = append([]string{args[0]}, "--file="+filepath.Base(args[1]))
349352
if len(args) > 2 {

pkg/system/bin.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package system
22

33
import "os"
44

5+
const BinEnvVar = "GPTSCRIPT_BIN"
6+
57
func Bin() string {
6-
bin := os.Getenv("GPTSCRIPT_BIN")
8+
bin := os.Getenv(BinEnvVar)
79
if bin != "" {
810
return bin
911
}

0 commit comments

Comments
 (0)