Skip to content

Commit 9e5f8f4

Browse files
fix: make the WorkspacePath take absolute precedence for setting env var
Before this change, the environment variables would take precedence for setting the GPTSCRIPT_WORKSPACE_DIR. This is incorrect because gptscript should be solely responsible for setting these environment variables. Putting these environment variables at the end of the list ensures that they take precedence. Co-authored-by: tylerslaton <[email protected]> Signed-off-by: Donnie Adams <[email protected]>
1 parent 51fd2b3 commit 9e5f8f4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/gptscript/gptscript.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ func (g *GPTScript) getEnv(env []string) ([]string, error) {
175175
if err := os.MkdirAll(g.WorkspacePath, 0700); err != nil {
176176
return nil, err
177177
}
178-
return slices.Concat(g.ExtraEnv, []string{
178+
return slices.Concat(g.ExtraEnv, env, []string{
179179
fmt.Sprintf("GPTSCRIPT_WORKSPACE_DIR=%s", g.WorkspacePath),
180180
fmt.Sprintf("GPTSCRIPT_WORKSPACE_ID=%s", hash.ID(g.WorkspacePath)),
181-
}, env), nil
181+
}), nil
182182
}
183183

184184
func (g *GPTScript) Chat(ctx context.Context, prevState runner.ChatState, prg types.Program, envs []string, input string) (runner.ChatResponse, error) {

0 commit comments

Comments
 (0)