Skip to content

runtime: prepend zsh fork bin dir to PATH#23768

Open
bolinfest wants to merge 1 commit into
pr23756from
pr23768
Open

runtime: prepend zsh fork bin dir to PATH#23768
bolinfest wants to merge 1 commit into
pr23756from
pr23768

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented May 20, 2026

Why

#23756 makes packaged Codex builds include and default to the bundled zsh fork. The follow-up runtime behavior is that zsh-fork executions should also put the folder containing that fork at the front of PATH, so scripts that use #!/usr/bin/env zsh resolve to the packaged fork instead of the system zsh.

Shell snapshots make this slightly more subtle: a snapshot can restore an older PATH after the child shell starts. This PR treats the zsh fork PATH prepend as an explicit environment override so snapshot wrapping preserves it.

What Changed

  • Added a shared zsh-fork runtime helper that prepends the configured zsh executable parent directory to PATH and records the resulting value as an explicit override.
  • Applied that helper to both zsh-fork shell_command launches and unified-exec zsh-fork launches before sandbox command construction.
  • Threaded the prepared environment through the shell-command zsh-fork backend instead of recomputing it later.
  • Added coverage for duplicate PATH entries and for preserving the zsh fork prepend through shell snapshot wrapping.

Testing

  • cargo test -p codex-core apply_zsh_fork_path_prepend
  • cargo test -p codex-core maybe_wrap_shell_lc_with_snapshot_preserves_zsh_fork_path_prepend
  • just fix -p codex-core

I also tried cargo test -p codex-core, but it currently aborts in unrelated thread_manager::tests::resume_and_fork_do_not_restore_thread_environments_from_rollout with a stack overflow. Rerunning that single test reproduces the same stack overflow.


Stack created with Sapling. Best reviewed with ReviewStack.

@bolinfest bolinfest requested a review from a team as a code owner May 20, 2026 22:18
@bolinfest bolinfest changed the base branch from main to pr23756 May 20, 2026 22:18
Summary:
- prepend the configured zsh fork executable directory to PATH for zsh-fork shell-command and unified-exec launches
- preserve that PATH value through shell snapshot wrapping so #!/usr/bin/env zsh can resolve to the packaged fork
- cover duplicate PATH entries and snapshot preservation in codex-core runtime tests

Test Plan:
- just fmt
- cargo test -p codex-core apply_zsh_fork_path_prepend
- cargo test -p codex-core maybe_wrap_shell_lc_with_snapshot_preserves_zsh_fork_path_prepend
- just fix -p codex-core

Notes:
- cargo test -p codex-core currently aborts in unrelated thread_manager::tests::resume_and_fork_do_not_restore_thread_environments_from_rollout with a stack overflow; rerunning that single test reproduces the same stack overflow.
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