Login shells override inherited PATH in curated environments; need configurable default

Open 💬 2 comments Opened Jan 8, 2026 by pikkili

What version of Codex is running?

codex-cli 0.77.0

What subscription do you have?

Using Codex via Oracle Enterprise‑hosted environment

Which model were you using?

gpt-5-codex

What platform is your computer?

Linux 5.15.0-315.193.2.el8uek.x86_64 x86_64 x86_64

What issue are you seeing?

Description
In curated environments (e.g., ADE or dev shells), codex inherits a carefully constructed PATH via config, but the default shell execution launches a login shell (bash -lc). Login shells re-run startup scripts and can override the inherited PATH, which causes tools from the curated environment to disappear.

This is surprising because config already controls environment inheritance via [shell_environment_policy], but it doesn’t prevent the login shell from reinitializing PATH afterward.

Expected behavior
If the user wants to preserve the inherited PATH, there should be a config option to default shell execution to a non‑login shell. The existing behavior must remain the default when the option is not set.

Proposed fix
Add a config option:

[shell]
default_login = true | false

Rules:

  • Default remains true when the option is absent (no behavior change).
  • Tool invocation login = true|false always overrides the config.
  • Applies to shell tools (shell, local_shell, shell_command).
  • Unified exec should keep its snapshot rule (when a snapshot exists and login is omitted, it stays non‑login).

Why this is a bug
In curated environments, PATH and related env vars are intentionally set. The current default login shell behavior undoes those env settings, leading to incorrect behavior that cannot be controlled via con

What steps can reproduce the bug?

1) Launch Codex in an environment where PATH is set by a wrapper after login (e.g., via a shell wrapper script).
2) In config.toml set:
[shell_environment_policy]
inherit = "all"
3) Run a shell tool command that relies on PATH (e.g., shell: echo $PATH or a tool in the curated PATH).
4) Observe that the command runs in a login shell (bash -lc) and PATH is reinitialized by startup scripts, losing the curated PATH.

Expected: PATH inherited from the parent environment is preserved.
Actual: PATH is overwritten by login shell initialization.

What is the expected behavior?

Shell tool commands should preserve the inherited PATH from the parent environment unless the user explicitly requests a login shell. The default
should remain login shells when the config option is not set.

Additional information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗