`codex app-server daemon` commands fail with `path must be shorter than SUN_LEN` when CODEX_HOME is a deep path (macOS)

Open 💬 3 comments Opened Jun 12, 2026 by Bohan-J

Summary

All codex app-server daemon client commands (version, start, stop, ...) derive the control socket path as $CODEX_HOME/app-server-control/app-server-control.sock. On macOS, the sun_path limit for Unix domain sockets is 104 bytes, so any CODEX_HOME longer than ~60 characters makes these commands fail before they can connect:

Error: failed to connect to <CODEX_HOME>/app-server-control/app-server-control.sock

Caused by:
    path must be shorter than SUN_LEN

There is currently no way to override the control socket location for the daemon client commands: codex app-server proxy accepts --sock, and the server side accepts --listen unix://PATH, but codex app-server daemon version/start/stop do not, and there is no config key or environment variable for it (the path is hardcoded in app_server_control_socket_path() in codex-rs/app-server-transport/src/transport/mod.rs).

Deep CODEX_HOME paths are common for tools that run Codex in isolated per-task or per-project homes (CI sandboxes, agent platforms, devcontainer setups), where the home lives inside a nested workspace directory and easily exceeds the budget.

Environment

  • macOS (Darwin 25.4.0, arm64)
  • codex-cli 0.137.0 (also reported on 0.139.0)

Reproduction

DEEP="/tmp/codex-sunlen-repro/$(printf 'a%.0s' {1..40})/$(printf 'b%.0s' {1..40})/codex-home"
mkdir -p "$DEEP"
echo "${#DEEP}"   # 116 chars
CODEX_HOME="$DEEP" codex app-server daemon version

Output:

Error: failed to connect to /private/tmp/codex-sunlen-repro/aaaa…aaaa/bbbb…bbbb/codex-home/app-server-control/app-server-control.sock

Caused by:
    path must be shorter than SUN_LEN

Note that pointing CODEX_HOME at a short symlink to the deep directory does not help: the home is canonicalized before the socket path is derived (visible above as /tmp resolving to /private/tmp), so the resolved long path still exceeds the limit.

Expected behavior

codex app-server daemon commands should work regardless of how deep CODEX_HOME is. Any of the following would solve it:

  1. An override for the control socket directory — a config key (e.g. app_server.control_socket_dir), an environment variable, or a --sock flag on the daemon subcommands (matching the existing codex app-server proxy --sock).
  2. A short hashed default location when the derived path would exceed the platform limit — e.g. $TMPDIR/codex-<hash-of-CODEX_HOME>/control.sock, similar to how OpenSSH solves the same problem with ControlPath %C.
  3. At minimum, a clearer error message that names CODEX_HOME length as the cause and suggests a workaround.

View original on GitHub ↗

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