Repository navigation
Description
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>&1After 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.logshows 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:
- New handoff to worktree doesn't use environments #18981: New handoff to worktree doesn't use environments
- Codex App Remote SSH new worktree does not discover repo-local skills #22545: Codex App Remote SSH new worktree does not discover repo-local skills
Possibly related setup/environment issues:
Activity
github-actions commentedon May 20, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
markusjura commentedon Oct 6, 2026
Same symptom over a remote-control connection (not Remote SSH), with one extra detail: the environment is never passed to worktree creation, so this isn't the setup script failing.
Version: ChatGPT desktop 26.930.51102 (build 13100), macOS. Client is one Mac, the project lives on a second Mac added under Connections (
remote-control:env_e_…).Setup: the repo tracks
.codex/environments/environment.tomlwithsetup.script = "zsh .worktree-setup.sh". Creating a worktree for the same repo as a local project picks up that environment automatically and runs the script.Repro:
What I found:
.git/worktrees/<name>/config.worktreecontainscodex.localEnvironmentConfigPath = __none__. Worktree creation writes__none__when it receives no config path, so the environment never reaches the setup step..codex-global-state.jsonunderlocal-env-selections-by-workspace, keyed by<hostId>:<projectPath>. The local project has an entry pointing at itsenvironment.toml. The remote project has none, and nothing in the UI creates one.environment.tomlfor the remote project. As far as I can tell from the app bundle, the composer resolves the environment without the "select default environment" option, so the resolved path staysnull.Expected: remote projects get the same default as local projects: the repo's environment is used automatically, and the setup script runs in the new remote worktree.