openai/codex · error · io::Error

AlreadyExists

AlreadyExists

Error message

failed to allocate proxy routing temp dir under {}

What it means

create_proxy_socket_dir could not create a fresh per-run directory for the bridge UDS sockets: all 128 candidate names under the shared temp root are taken (or creation fails, e.g. the temp root is full or not writable). The directory is created with 0o700 mode because it lives under a shared parent traversable by other processes.

Solutions

  1. Clear stale codex proxy socket directories left by crashed runs under the temp root and retry
  2. Verify the temp dir (from proxy_socket_parent_dir) exists and is writable by the current uid
  3. If exhaustion is systematic, file a bug to widen the attempt range or prune old directories automatically
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/linux-sandbox/src/proxy_routing.rs:325 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/a4378886a3768081. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/linux-sandbox/src/proxy_routing.rs:325

}

fn create_proxy_socket_dir() -> io::Result<PathBuf> {
    let temp_dir = proxy_socket_parent_dir();
    let pid = std::process::id();
    let uid = unsafe { libc::geteuid() };
    for attempt in 0..128 {
        let candidate = temp_dir.join(format!("{PROXY_SOCKET_DIR_PREFIX}{pid}-{uid}-{attempt}"));
        // The bridge UDS paths live under a shared temp root, so the per-run
        // directory should not be traversable by other processes.
        let mut dir_builder = DirBuilder::new();
        dir_builder.mode(0o700);
        match dir_builder.create(&candidate) {
            Ok(()) => return Ok(candidate),
            Err(err) if err.kind() == io::ErrorKind::AlreadyExists => continue,
            Err(err) => return Err(err),
        }
    }
    Err(io::Error::new(
        io::ErrorKind::AlreadyExists,
        format!(
            "failed to allocate proxy routing temp dir under {}",
            temp_dir.display()
        ),
    ))
}

fn proxy_socket_parent_dir() -> PathBuf {
    if let Some(codex_home) = std::env::var_os("CODEX_HOME") {
        let candidate = PathBuf::from(codex_home).join("tmp");
        if proxy_socket_paths_fit(candidate.as_path())
            && ensure_private_proxy_socket_parent_dir(candidate.as_path()).is_ok()
        {
            return candidate;
        }
    }
    let temp_dir = std::env::temp_dir();

View on GitHub (pinned to 339751715c)