Codex App Remote SSH new worktree does not run local environment setup script
Summary
When using Codex App against a Remote SSH project, creating a new worktree thread with an environment configured in the remote repository does not run that environment.toml setup script at all.
To avoid ambiguity: by "environment" here I mean Codex's Local environments feature, but in this reproduction the environment.toml being modified is in the repository on the remote SSH host, not on my local client machine.
I confirmed this with a minimal setup script that only appends diagnostics to /tmp on the remote host. The new worktree/thread is created, but the log file is never written, so this looks like the setup script is not invoked for the Remote SSH + New worktree path, rather than a failure inside the script.
Expected behavior
If an environment from the remote repository is selected when starting a new worktree thread, Codex should run that environment's setup script before the thread starts using the new worktree.
This is also the behavior implied by the Local environments and Worktree documentation: setup scripts are expected to run when Codex creates a new worktree / starts a new thread with a selected environment. Since Codex App Remote SSH threads run against the remote filesystem and shell, the selected repo environment should be applied there too.
Actual behavior
The new worktree is created and the thread starts, but the selected environment's setup script is never called.
A diagnostic setup script like this produces no output on the remote host:
{
echo "=== codex setup $(date) ==="
echo "pwd=$PWD"
echo "whoami=$(whoami)"
echo "git_root=$(git rev-parse --show-toplevel 2>/dev/null || true)"
env | grep -E '^(CODEX|SSH|SHELL|PWD|HOME)=' | sort
} >> /tmp/codex-setup-debug.$USER.log 2>&1
After creating a Remote SSH new worktree thread and selecting that repository environment, checking the remote host with:
tail -n 200 /tmp/codex-setup-debug.$USER.log
shows that no setup log was written.
Reproduction steps
- Open Codex App.
- Connect to a project through Remote SSH.
- On the remote SSH host, modify the repository's environment configuration (
environment.toml) so its setup script writes to/tmp, for example the script above. - From that Remote SSH project, create a new worktree thread.
- Select that repository environment for the new worktree thread.
- Wait for the thread to start.
- On the remote host, inspect
/tmp/codex-setup-debug.$USER.log.
Result
No log entry is created. The setup script appears not to be invoked at all.
Related issues
This seems related to other cases where new worktree flows do not correctly carry environment or project-local configuration:
- #18981: New handoff to worktree doesn't use environments
- #22545: Codex App Remote SSH new worktree does not discover repo-local skills
Possibly related setup/environment issues:
- #10543
- #11223
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗