macOS sandboxed shell commands start with C.UTF-8, causing bash setlocale warnings before shell_environment_policy.set is applied
What version of Codex CLI is running?
codex-cli 0.121.0
What subscription do you have?
pro
Which model were you using?
gpt-5.4
What platform is your computer?
uname -mprs Darwin 23.6.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
iterm2, bash
What issue are you seeing?
Sandboxed shell commands in Codex CLI start with C.UTF-8 in the locale environment on macOS, which causes Bash to emit locale warnings
before running the command:
/opt/homebrew/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory
/opt/homebrew/bin/bash: line 12: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory
This happens even though C.UTF-8 is not an available locale on this macOS system.
I also tried forcing a valid macOS locale via ~/.codex/config.toml, but the warning still appears, which suggests the invalid locale is
being set before shell_environment_policy.set is applied.
What steps can reproduce the bug?
- Start a fresh codex session on macOS.
- Run a simple shell command such as:
locale
or:
curl -I https://www.google.com
- Observe the startup warnings from /opt/homebrew/bin/bash.
What is the expected behavior?
Codex should not initialize sandboxed shell commands with C.UTF-8 on macOS, since that locale is not available there.
Expected behavior would be one of:
- use en_US.UTF-8 on macOS
- use C
- or apply shell_environment_policy.set early enough that Bash never starts with C.UTF-8
Additional information
codex is installed via Homebrew and resolves to:
/opt/homebrew/bin/codex
On this machine, locale -a includes:
en_US
C
POSIX
and does not include C.UTF-8.
In a fresh Codex-run command, locale reports that LANG is initially C.UTF-8, and Bash warns before the command completes. The final
locale output falls back to LC_ALL="C".
I added this to ~/.codex/config.toml:
[shell_environment_policy]
inherit = "core"
experimental_use_profile = true
include_only = ["PATH","HOME","GEM_HOME","GEM_PATH","MY_RUBY_HOME"]
set = { LANG = "en_US.UTF-8", LC_ALL = "en_US.UTF-8" }
but the warnings still occur, so it looks like the invalid locale is set before user-configured environment overrides are applied.
This appears to be a macOS-specific sandbox/command-launch locale initialization bug.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗