Skip to content

Codex App Remote SSH new worktree does not run local environment setup script #23648

Open

Description

@SDGLBL

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

  1. Open Codex App.
  2. Connect to a project through Remote SSH.
  3. 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.
  4. From that Remote SSH project, create a new worktree thread.
  5. Select that repository environment for the new worktree thread.
  6. Wait for the thread to start.
  7. 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:

Possibly related setup/environment issues:

Activity

  1. added
    bug
    app
    config
    on May 20, 2026
  2. github-actions commented on May 20, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. markusjura commented on Oct 6, 2026

    @markusjura

    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.toml with setup.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:

    1. Add the repo on the remote host as a remote project.
    2. Start a new chat in that project with the Worktree checkbox enabled.
    3. The worktree is created and the chat starts, but no "Setting up environment" step appears and the script never runs.

    What I found:

    • On the remote host, the new worktree's .git/worktrees/<name>/config.worktree contains codex.localEnvironmentConfigPath = __none__. Worktree creation writes __none__ when it receives no config path, so the environment never reaches the setup step.
    • The composer has no environment picker for either local or remote projects, only the Worktree checkbox. So there is no way to select the environment for the remote project by hand.
    • The client stores selections in .codex-global-state.json under local-env-selections-by-workspace, keyed by <hostId>:<projectPath>. The local project has an entry pointing at its environment.toml. The remote project has none, and nothing in the UI creates one.
    • With no saved selection, the composer doesn't fall back to the repo's only environment.toml for 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 stays null.

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugconfigremote

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions