openai/codex · error

failed to resolve synthetic mount registry temp directory

Error message

failed to resolve synthetic mount registry temp directory {}: {err}

What it means

Canonicalizing the temp directory failed while resolving where the synthetic mount registry lives. This panic in synthetic_mount_registry_root fires when std::env::temp_dir().canonicalize() errors — the temp path exists per env but cannot be resolved to a real path (deleted TMPDIR, symlink loops, permission issues) — so the registry root cannot be established for this uid.

Solutions

  1. Verify TMPDIR points to an existing, accessible directory
  2. Recreate the temp directory if it was deleted out from under the process
  3. Fix or remove cyclic symlinks in the temp path
  4. Set TMPDIR to a simple local path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1344 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/0877e5d320de7325. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1344

            lock_path.display()
        );
    }
    result
}

fn synthetic_mount_marker_dir(path: &Path) -> PathBuf {
    synthetic_mount_registry_root().join(format!("{:016x}", hash_path(path)))
}

pub(crate) fn synthetic_mount_registry_root() -> PathBuf {
    static REGISTRY_ROOT: OnceLock<PathBuf> = OnceLock::new();

    REGISTRY_ROOT
        .get_or_init(|| {
            let effective_uid = unsafe { libc::geteuid() };
            let temp_dir = std::env::temp_dir();
            let temp_dir = temp_dir.canonicalize().unwrap_or_else(|err| {
                panic!(
                    "failed to resolve synthetic mount registry temp directory {}: {err}",
                    temp_dir.display()
                )
            });
            let registry_root = temp_dir.join(format!(
                "codex-bwrap-synthetic-mount-targets-{effective_uid}"
            ));
            // A registry symlink can redirect bookkeeping into a writable root
            // that does not overlap TMPDIR, bypassing its read-only mount.
            assert!(
                !registry_root.is_symlink(),
                "synthetic mount registry must not be a symlink: {}",
                registry_root.display()
            );
            registry_root
        })
        .clone()
}

View on GitHub (pinned to 339751715c)