What version of Codex CLI is running?
codex-cli 0.116.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.4
What platform is your computer?
Linux 6.12.74+deb13+1-amd64 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
No response
What issue are you seeing?
In Codex 0.116.0, commands installed via Nix are available to the parent Codex process, but unavailable to tool commands executed through bash -lc.
The shell snapshot appears to serialize an inconsistent environment:
- it preserves
NIX_PROFILES
- it preserves
__ETC_PROFILE_NIX_SOURCED=1
- but it rewrites
PATH to only system directories
Because of that, later shell startup does not restore Nix paths: /etc/profile.d/nix.sh runs, but its delegated script exits early because __ETC_PROFILE_NIX_SOURCED is already set.
What steps can reproduce the bug?
- Start Codex in a Nix-based shell environment where the parent process
PATH includes Nix profile bins.
- Run a tool command through Codex such as:
- Observe that it fails.
- Inspect the generated shell snapshot and compare its
PATH to the parent process environment.
What is the expected behavior?
Commands available in the parent Codex environment should remain available in tool shell commands.
At minimum, if the snapshot preserves __ETC_PROFILE_NIX_SOURCED=1, it should also preserve the corresponding Nix-modified PATH.
Actual
The parent process has the correct Nix PATH, but the generated shell snapshot contains a reduced PATH. As a result, commands installed in the Nix profile are not found from bash -lc.
Example symptom:
command -v rg
# exits non-zero
Additional information
Evidence
Parent sandbox process environment includes Nix paths:
PATH=/tmp/codex-arg0/...:/nix/store/...-ripgrep-15.1.0/bin:/home/<user>/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:...
NIX_PROFILES=/nix/var/nix/profiles/default /home/<user>/.nix-profile
__ETC_PROFILE_NIX_SOURCED=1
SHELL=/home/<user>/.nix-profile/bin/fish
Generated shell snapshot contains:
declare -x NIX_PROFILES="/nix/var/nix/profiles/default /home/<user>/.nix-profile"
declare -x PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
declare -x SHELL="/home/<user>/.nix-profile/bin/fish"
declare -x __ETC_PROFILE_NIX_SOURCED="1"
Then bash -x -lc true shows shell init loading Nix startup, but it short-circuits immediately:
+ . /etc/profile.d/nix.sh
++ . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
+++ '[' -n 1 ']'
+++ return
So the shell snapshot has already made the environment inconsistent before command execution begins.
Likely root cause
The shell snapshot generator is reconstructing or sanitizing PATH incorrectly while preserving related Nix environment variables verbatim.
Suggested fix
One of:
- Preserve the actual inherited
PATH in the shell snapshot.
- Do not preserve
__ETC_PROFILE_NIX_SOURCED unless the snapshot also preserves the matching Nix PATH.
- Recompute the environment in a way that keeps Nix init state internally consistent.
Workaround
A local shell workaround is to prepend the Nix profile bin explicitly in user startup files, but this looks like a Codex environment snapshot bug rather than a user shell configuration problem.
What version of Codex CLI is running?
codex-cli 0.116.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.4
What platform is your computer?
Linux 6.12.74+deb13+1-amd64 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
No response
What issue are you seeing?
In Codex
0.116.0, commands installed via Nix are available to the parent Codex process, but unavailable to tool commands executed throughbash -lc.The shell snapshot appears to serialize an inconsistent environment:
NIX_PROFILES__ETC_PROFILE_NIX_SOURCED=1PATHto only system directoriesBecause of that, later shell startup does not restore Nix paths:
/etc/profile.d/nix.shruns, but its delegated script exits early because__ETC_PROFILE_NIX_SOURCEDis already set.What steps can reproduce the bug?
PATHincludes Nix profile bins.command -v rgPATHto the parent process environment.What is the expected behavior?
Commands available in the parent Codex environment should remain available in tool shell commands.
At minimum, if the snapshot preserves
__ETC_PROFILE_NIX_SOURCED=1, it should also preserve the corresponding Nix-modifiedPATH.Actual
The parent process has the correct Nix
PATH, but the generated shell snapshot contains a reducedPATH. As a result, commands installed in the Nix profile are not found frombash -lc.Example symptom:
Additional information
Evidence
Parent sandbox process environment includes Nix paths:
Generated shell snapshot contains:
Then
bash -x -lc trueshows shell init loading Nix startup, but it short-circuits immediately:So the shell snapshot has already made the environment inconsistent before command execution begins.
Likely root cause
The shell snapshot generator is reconstructing or sanitizing
PATHincorrectly while preserving related Nix environment variables verbatim.Suggested fix
One of:
PATHin the shell snapshot.__ETC_PROFILE_NIX_SOURCEDunless the snapshot also preserves the matching NixPATH.Workaround
A local shell workaround is to prepend the Nix profile bin explicitly in user startup files, but this looks like a Codex environment snapshot bug rather than a user shell configuration problem.