Skip to content

fix(run_shell): inherit parent environment in spawned shell#196

Open
qu0b wants to merge 1 commit into
ethpandaops:masterfrom
qu0b:qu0b/fix/run-shell-env-inherit
Open

fix(run_shell): inherit parent environment in spawned shell#196
qu0b wants to merge 1 commit into
ethpandaops:masterfrom
qu0b:qu0b/fix/run-shell-env-inherit

Conversation

@qu0b

@qu0b qu0b commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds command.Env = append(command.Env, os.Environ()...) before the user-supplied envVars in pkg/tasks/run_shell/task.go
  • When exec.Cmd.Env is set to a non-nil slice, Go does not inherit the parent environment — HOME, PATH, USER, SHELL are all unset in the child process
  • User-supplied envVars from the task config are still appended after, so they continue to override inherited values

Why this matters

Without this fix, two common patterns silently break:

  1. pip install --user tools (e.g. uv) install to $HOME/.local/bin. With $HOME unset, ~/.profile never adds that directory to PATH, so the binary is not found (exit 127)
  2. foundryup reads $SHELL to decide which profile to update. With $SHELL unset it exits 1

Both were worked around in playbooks with sudo pip install and export SHELL=/bin/bash, but fixing it at the task level is cleaner.

Test plan

  • run_shell task with pip install --user somepackage && somepackage --version succeeds without export PATH workaround
  • run_shell task running foundryup succeeds without export SHELL=/bin/bash prefix

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant