Repository navigation
Description
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 versionOutput:
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:
- An override for the control socket directory — a config key (e.g.
app_server.control_socket_dir), an environment variable, or a--sockflag on thedaemonsubcommands (matching the existingcodex app-server proxy --sock). - 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 withControlPath %C. - At minimum, a clearer error message that names
CODEX_HOMElength as the cause and suggests a workaround.
Activity
wgu9 commentedon Jun 15, 2026
I checked current
mainand this still looks like a single choke point rather than a daemon-only bug.The default control socket path is built in
codex-rs/app-server-transport/src/transport/mod.rs:That same helper is used by:
codex-rs/app-server-daemon/src/lib.rsinDaemon::from_environment()for lifecycle commands such asversion,start,stop, etc.AppServerTransport::from_listen_url("unix://"), so the default Unix listener path has the same long-CODEX_HOMEexposure.codex app-server proxywhen--sockis omitted.So I would avoid fixing this only in the CLI command parser. A more robust fix would make
app_server_control_socket_path()return a platform-safe path by default, or add a single resolver beside it that all default-control-socket callers use.Patch shape that seems low-risk:
$CODEX_HOME/app-server-control/app-server-control.sockpath while it is short enough.CODEX_HOME, for example$TMPDIR/codex-app-server/<hash>/control.sock.CODEX_HOME; only the UDS rendezvous path needs to move.codex-rs/app-server-transport/src/transport/unix_socket_tests.rsfor a deepCODEX_HOMEand for stable hashing, plus one daemon/client smoke test if the final API surface changes.One small test detail:
find_codex_home()canonicalizesCODEX_HOME, so the regression test should create the deep directory first and assert against the canonical path length. That matches the reported/tmp->/private/tmpbehavior on macOS.kyoh86 commentedon Jun 26, 2026
I can reproduce the same failure on Ubuntu 24.04.4 LTS on WSL2.
Environment:
codex-cli 0.142.26.6.87.2-microsoft-standard-WSL22.6.3.0x86_64In my case this shows up when
CODEX_HOMEis configured under an XDG-style config path and resolves to a long path. The symlink/dotfiles detail is only one way to hit the issue; the underlying problem is that runtime socket paths are derived fromCODEX_HOME.I also think it would be useful to separate the default location question from the override question:
CODEX_HOMEby default.XDG_RUNTIME_DIRseems like a more appropriate default for runtime files.XDG_RUNTIME_DIRcan also be unsuitable in some environments, so a Codex-specific override such asCODEX_RUNTIME_DIRorCODEX_APP_SERVER_RUNTIME_DIRwould still be valuable.So the desired shape from my perspective would be:
CODEX_HOME.XDG_RUNTIME_DIRon Linux.nezc commentedon Jul 10, 2026
I can reproduce this through Codex Desktop SSH to a Linux remote.
26.707.31428(build5059) on macOS 15.7.3codex-cli 0.144.1/rootis a symlink to a deeply nested persistent-volume pathSSH public-key authentication, the remote shell/version probes, and app-server bootstrap all succeed. The failure occurs when Desktop runs
codex app-server proxy:Desktop then surfaces only
ECONNRESET: socket hang up, making this look like an SSH/network failure.This confirms the same path-length bug also blocks the Desktop SSH flow. A short symlink does not help because
CODEX_HOMEis canonicalized; using a genuinely short real path/bind mount works around it.tsuvic commentedon Aug 7, 2026
Still reproduces on current macOS builds (arm64), identically on both:
Including the
/tmp→/private/tmpcanonicalization that defeats short-symlink workarounds.Update — traced to a single choke point on current main:
app_server_control_socket_path()(codex-rs/app-server-transport/src/transport/mod.rs:54–62) always returnsCODEX_HOME/app-server-control/app-server-control.sock(+44 bytes), andfind_codex_home()canonicalizes aCODEX_HOMEenv value (codex-rs/utils/home-dir/src/lib.rs:45), hence/private/tmp.os/unix/net/addr.rs): macOSsun_pathis 104 bytes, so the usable budget for CODEX_HOME is 103 − 44 = 59 bytes.codex doctor,app-server proxy) funnels through that one function — which is also whydoctormisreports "stale or unreachable" here.The repo already solves this exact problem two other places:
codex-rs/linux-sandbox/src/proxy_routing.rs:58(UNIX_SOCKET_PATH_MAX_BYTES+/tmpfallback chain) andcodex-rs/tui/src/ide_context/ipc.rs:179–190($TMPDIR/codex-ipc/…fallback + explicitsockaddr_unlength checks). The control socket is the last unhandled site.Suggested fix (hybrid, zero migration): keep the classic path when it fits (≤103 bytes — every currently working install); otherwise fall back to a deterministic short path both daemon and clients can compute with no I/O:
(Linux: prefer
$XDG_RUNTIME_DIR/codex; root dir verified uid-owned + 0700.) Collision safety can be hardened for free by checkingInitializeResponse.codex_homeon fallback probes. Deep-CODEX_HOME installs are fully broken today, so there is nothing to stay compatible with.tsuvic commentedon Aug 19, 2026
Still reproduces on 0.148.0 (release binary, macOS arm64), identically to 0.137–0.147:
Including the
/tmp→/private/tmpcanonicalization (+8 bytes) that defeats short-symlink workarounds.On current main the single choke point is unchanged:
app_server_control_socket_path()(codex-rs/app-server-transport/src/transport/mod.rs:58–64) still has no length handling, and every producer/consumer (daemon bind/connect, TUI auto-connect,codex doctor,app-server proxy) funnels through it. The hybrid fallback suggested in my earlier comment (keep the classic path when ≤103 bytes, otherwise a deterministic hashed short path both sides can compute without I/O) still applies; the in-tree templates for exactly this remaincodex-rs/linux-sandbox/src/proxy_routing.rsandcodex-rs/tui/src/ide_context/ipc.rs.seonghoshim commentedon Aug 26, 2026
I can confirm that this still reproduces on Codex CLI 0.149.1 when launched through Orca, which uses an isolated per-account
CODEX_HOME.Environment
CODEX_HOMElength: 108 bytesThe generated path has this form:
LuizPiccini commentedon Sep 25, 2026
Still reproduces on codex-cli 0.157.0 (Homebrew cask, macOS arm64), and 0.157.0 makes it more visible: plain
codexnow installs and starts the managed daemon on launch, so a deepCODEX_HOMEbreaks the default interactive launch rather than onlycodex app-server daemon ....CODEX_HOMEhere is an Orca per-account home (~/Library/Application Support/orca/codex-accounts/<uuid>/home), giving a 147-byte socket path.New detail: in 0.157.0 the listener side already has a short-path fallback, but the client side does not use it. After the failed launch:
.../app-server-daemon/releases/0.157.0-aarch64-apple-darwin/bin/codex app-server --listen unix:// ...)./private/tmp/codex-daemon-501/<sha256>, where<sha256>is the SHA-256 of the full long socket path.<CODEX_HOME>/app-server-control/app-server-control.sockwas a symlink to that short socket.So the server is reachable, but the client still passes the long symlink path to
connect(), and Rust std rejects it for length before the kernel could follow the link. Making the connect side compute the same fallback path (/tmp/codex-daemon-<uid>/sha256(<derived path>)) when the derived path exceeds the limit looks like the missing half of the fix.Workaround confirmed: move the real home to a short path and leave the long path as a symlink to it. Because
find_codex_home()canonicalizes, the derived socket path becomes short (60 bytes here):The opposite symlink (short link pointing at the long home) does not help, as noted above.
hpg-mheck commentedon Sep 25, 2026
Confirmed on Rocky Linux 10.2, x86_64, with codex-cli 0.157.0 installed from
@openai/codexvia npm. This blocks ordinary interactive startup with a project-local isolated HOME, not just explicit daemon commands.Our affected installation has a 111-byte advertised control socket pathname. Installation and
codex --versionsucceeded, but plain interactive startup waited roughly a minute and then reported:Linux confirmation of the listener/client mismatch described above: after the failed launch, the daemon was still running. The long advertised socket pathname was a symlink to
/tmp/codex-daemon-<uid>/<64-hex-digest>. The target was an actual socket with mode0600; its physical pathname was only 87 bytes on this machine. The client nevertheless reported the overlong advertised pathname.I also tested
codex app-server daemon versionwith fresh, credential-free temporary homes and exact socket-path byte lengths:No such file or directory (os error 2), expected because this disposable home has no daemonpath must be shorter than SUN_LENpath must be shorter than SUN_LENReproduction of the boundary, without starting a daemon or making model requests:
Codex additionally warns about not creating PATH helper aliases under
/tmpin this disposable reproduction; the original interactive failure occurs with persistent project-local state outside/tmp.Workaround verified: adding
--no-daemonto the original launcher reached the actual interactive prompt with the configured model and project loaded, while retaining the same HOME, authentication, and session storage. It bypasses daemon functionality.The existing short physical socket makes a shared, security-checked client/server socket resolver look preferable to relocating persistent
CODEX_HOME. A regression test should cover a real listener plus a client connecting through an overlong advertised alias, in addition to boundary-length checks.Kooooojun commentedon Sep 25, 2026
補充確認:0.157.0/Ubuntu 24.04 WSL2/Windows Orca,以及搬移 home 的相容性限制
此問題也會阻擋 Windows Orca 管理的 WSL Codex 帳號啟動。
環境
CODEX_HOME形式:/home/<user>/.local/share/orca/codex-accounts/<account-id>/home實際錯誤與更新差異
執行
codex --yolo後:codex app-server daemon version也會因同一路徑限制失敗。版本原始碼顯示,0.156.1 的
daemon_auto_start為 experimental、預設 false,0.157.0 改成 stable、預設 true。這解釋了為何既有長目錄在更新後開始阻擋一般互動啟動,而不只是顯式 daemon 命令。隔離重現:短實體 socket 可以使用
另以不含登入資料的臨時長
CODEX_HOME啟動codex app-server --listen unix://,實測:AF_UNIX path too long/tmp/codex-daemon-<uid>/<hash>initialize成功,服務回報 0.157.0此測試未發送模型 prompt;臨時服務已停止、測試目錄已清理。它支持前述 listener/client 路徑不一致的診斷:服務端可以提供短實體 socket,但預設客戶端仍嘗試連過長的 alias。
重要限制:搬移實體 home 並留下 symlink 不適合此 Windows Orca 環境
曾把帳號實體 home 搬到短路徑,並在 Orca 原位置留下指向短路徑的 Linux 絕對 symlink。當時:
daemon version回報 running;codex --yolo能連上 daemon 並進入 Ready。該改動已完整撤回:home 恢復原位置的實體目錄。Windows
Test-Path與System.IO.Directory.CreateDirectory均再次成功,Orca 也恢復正常。因此,搬移持久帳號資料不是此跨平台整合環境的可行通用解法;此處只回報觀察到的行為,不推論所有 Windows/WSL symlink 均不可用。目前可用的 workaround
保留原 Orca home,在既有
[features]區段設定:一般 Codex 與 Orca 可以使用,但這會放棄自動共用 daemon,並非根治。
希望修正預設客戶端的 socket resolver,讓它在維持使用者/路徑安全檢查的前提下,與服務端使用同一個短實體 socket;不需要搬動
CODEX_HOME。建議回歸測試涵蓋超長 home 的 listener + client,以及在原帳號目錄完全不變的情況下恢復正常 daemon 連線。brennanb2025 commentedon Sep 25, 2026
This is also hitting me, and since 0.157 it's severe: plain
codexno longer starts at all. It isn't limited to thecodex app-server daemonsubcommands anymore. Every launch in a Codex home deeper than about 60 bytes (macOS) or 64 (Linux) fails withapp server did not become ready ... path must be shorter than SUN_LEN. That covers every per-account home created by tools like Orca, so affected users get a CLI that refuses to start until they know to pass--no-daemon. It also leaves an orphaned daemon running after each failed launch. Since 0.157 turned on daemon auto-start by default, this is now a startup blocker, not an edge case.The server side already handles a deep
CODEX_HOME:start_control_socket_acceptorbinds a short socket at/tmp/codex-daemon-<uid>/<sha256>and publishes<CODEX_HOME>/app-server-control/app-server-control.sockas a symlink to it. The client side never gets that far. Every client connects through the long symlink path, and Rust'sUnixStream::connectrejects any path longer thansun_path(104 bytes on macOS, 108 on Linux) before callingconnect(2), so the kernel never follows the symlink.That affects every client on this path: the TUI's default-daemon probe,
codex app-server daemon start(its readiness wait fails even though the daemon is up and bound),daemon version,app-server proxy, and the remote app-server client. On 0.157 the daemon is left running, unused, after plaincodexfails.It starts once
CODEX_HOMEis longer than 60 bytes on macOS (64 on Linux), which tools that keep a per-account Codex home (Orca among them) reach easily.A possible fix: in
codex_uds's Unix connect, when the path does not fit insun_path, connect to the protected socket instead, but only if the rendezvous path is a symlink whose target is exactly the protected path recomputed the way the listener computes it, and the shared daemon directory is still user-owned with mode0700. Paths that fit behave as before, and every caller is covered from one place.goodman-oai commentedon Nov 16, 2026
Closing as completed. The long control-socket path fix shipped in 0.159.0 via #48772. On macOS with 0.169.0,
codex app-server daemon versionconnected to a running app-server and returned its version with a 154-byteCODEX_HOME.