macOS: LC_ALL forced to C.UTF-8 in codex CLI shell commands (unified exec)
What version of Codex is running?
codex-cli 0.84.0
What subscription do you have?
Pro
Which model were you using?
5.2-codex
What platform is your computer?
Darwin 23.6.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
iTerm2
What issue are you seeing?
When running shell commands via codex-cli on macOS, LC_ALL is forcibly set to C.UTF-8 even if the user’s locale is different. Note that C.UTF-8 is not usually available on MacOS. This happens without user opt-in and affects command behavior that depends on locale. In particular it can lead to various commands printing warning messages. It appears to come from unified exec environment injection.
Steps to Reproduce
- On macOS, run Codex CLI (TUI).
- Enter prompt:
Run "env | egrep '^(LANG|LC_)'" and report the result
- Observe output contains LC_ALL=C.UTF-8.
Expected Result:
LC_ALL should reflect the user’s environment (or be unset), unless explicitly configured by the user or the command.
Actual Result:
LC_ALL is always set to C.UTF-8.
Suspected Cause
Unified exec injects a fixed locale, including LC_ALL=C.UTF-8, for all unified exec processes.
- codex-rs/core/src/unified_exec/process_manager.rs:50 (UNIFIED_EXEC_ENV)
- codex-rs/core/src/unified_exec/process_manager.rs:486 (applies env)
Workarounds
- Disable unified exec for the session: codex --disable unified_exec …
- Run locally with ! in the TUI (bypasses unified exec)
- Override in the command: LC_ALL= LANG= LC_CTYPE= env | egrep '^(LANG|LC_)'
What steps can reproduce the bug?
- On macOS, run Codex CLI (TUI).
- Enter prompt:
Run "env | egrep '^(LANG|LC_)'" and report the result
- Observe output contains LC_ALL=C.UTF-8.
What is the expected behavior?
_No response_
Additional information
_No response_
2 Comments
I'm running into this. I use nixpkgs provided bash. My locale output for a login shell is
This looks correct to me. Codex tells me that its related variables are set to:
So this seems to be set by codex.
My concern is that pollutes the context and adds unnecessary tokens.
Hey! I ran into a similar pattern in our bug knowledge base and thought this might help.
What's happening: codex-rs/core/src/unified_exec/process_manager.rs line ~50: UNIFIED_EXEC_ENV constant hardcodes LC_ALL=C.UTF-8 for all spawned processes. C.UTF-8 is not a valid locale on macOS (only Linux glibc), causing warnings and overriding user locale.
What worked for us:
Remove the LC_ALL=C.UTF-8 entry from UNIFIED_EXEC_ENV. Instead, inherit the user's existing locale environment (LANG, LC_ALL, LC_CTYPE). If UTF-8 safety is needed, only set LC_CTYPE=UTF-8 as fallback when no locale vars are already defined.
Hope this helps! Let me know if it doesn't match your case — happy to dig deeper. 🦞
---
<sub>🦞 Confucius Debug — community knowledge base for AI agent bugs. Free to search via MCP.</sub>