From 4db01f20bd1bb26d8a2dbeee308776bc65fc79cd Mon Sep 17 00:00:00 2001 From: qu0b Date: Tue, 23 Jun 2026 07:54:35 +0000 Subject: [PATCH] fix(run_shell): inherit parent environment in spawned shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this, exec.Cmd.Env is nil-initialized and the child process receives no environment — HOME, PATH, USER, SHELL are all unset. Scripts that rely on user-installed binaries (e.g. uv via pip install --user) or shell detection (e.g. foundryup checking $SHELL) fail with exit 127 or exit 1. User-supplied envVars in the task config still override inherited values via append order. --- pkg/tasks/run_shell/task.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/tasks/run_shell/task.go b/pkg/tasks/run_shell/task.go index fc5aaeba..c8701f73 100644 --- a/pkg/tasks/run_shell/task.go +++ b/pkg/tasks/run_shell/task.go @@ -101,6 +101,11 @@ func (t *Task) Execute(ctx context.Context) error { //nolint:gosec // ignore command := exec.CommandContext(ctx, t.config.Shell, t.config.ShellArgs...) + // Inherit parent environment so spawned shells have HOME/PATH/USER. + // Without this, exec.Cmd.Env is nil and the child inherits nothing; + // user-supplied envVars below still take precedence via append order. + command.Env = append(command.Env, os.Environ()...) + stdin, err := command.StdinPipe() if err != nil { cmdLogger.Errorf("failed getting stdin pipe")