codex - 💡(How to fix) Fix app-server local command execution lacks a cwd-scoped environment contract

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

This is surprising and operationally risky because the UI presents both sessions as local command execution in the same directory, but env-sensitive commands may behave differently.

Code Example

mkdir -p /tmp/codex-env-repro
cd /tmp/codex-env-repro
export CODEX_ENV_REPRO=present
printenv CODEX_ENV_REPRO

---

present

---

codex

---

pwd
printenv CODEX_ENV_REPRO

---

/private/tmp/codex-env-repro
# no output

---

codex -c shell_environment_policy.inherit=all

---

pwd
printenv CODEX_ENV_REPRO

---

/tmp/codex-env-repro
present
RAW_BUFFERClick to expand / collapse

What issue are you seeing?

Codex local command execution can silently use different environment sources for visually similar TUI launches.

A plain codex session may reuse an implicit local app-server daemon. Adding any -c override prevents that reuse and starts a different execution topology. This means command env can differ even when cwd and the visible UI look equivalent.

This is surprising and operationally risky because the UI presents both sessions as local command execution in the same directory, but env-sensitive commands may behave differently.

What steps can reproduce the bug?

First, make sure an implicit local app-server daemon already exists. In my case, this was a long-lived daemon started earlier by normal Codex use. The important precondition is that plain codex can reuse an existing local app-server daemon.

Then, in a shell:

mkdir -p /tmp/codex-env-repro
cd /tmp/codex-env-repro
export CODEX_ENV_REPRO=present
printenv CODEX_ENV_REPRO

Control output:

present

Start Codex normally:

codex

Inside Codex:

pwd
printenv CODEX_ENV_REPRO

Observed:

/private/tmp/codex-env-repro
# no output

Now exit and start Codex with a config override:

codex -c shell_environment_policy.inherit=all

Inside Codex:

pwd
printenv CODEX_ENV_REPRO

Observed:

/tmp/codex-env-repro
present

What is the expected behavior?

Either:

  1. both local TUI launches use the same command-env provenance, or
  2. Codex clearly exposes when command env comes from a reused app-server daemon instead of the launching terminal process.

The important part is not this specific variable. The issue is that adding a -c override changes process topology and therefore command env, while the UI still presents both as local execution in the selected cwd.

Additional information

shell_environment_policy.inherit = "all" appears to be valid and already defaults to all, so the override value itself is probably not the fix. The relevant behavior appears to be that non-empty CLI overrides prevent implicit local app-server daemon reuse.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix app-server local command execution lacks a cwd-scoped environment contract