Skip to content

Commit 503bd05

Browse files
authored
Merge pull request #477 from thedadams/system-bin-cleanup
chore: ensure gptscript stack uses the same binary
2 parents a2e23a5 + f830707 commit 503bd05

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/cli/gptscript.go

+4-1
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

+3-1
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)