{"record":{"id":"138582939656db11","repo":"openai/codex","slug":"invalidinput-138582","errorCode":"InvalidInput","errorMessage":"Refusing to create helper binaries under temporary dir {temp_root:?} (codex_home: {codex_home:?})","messagePattern":"Refusing to create helper binaries under temporary dir (.+?) \\(codex_home: (.+?)\\)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/arg0/src/lib.rs","lineNumber":347,"sourceCode":"///   with the hidden `--codex-run-as-apply-patch` flag.\n///\n/// Returns the temporary directory guard and the PATH value that prepends the\n/// temporary directory so `apply_patch` can be on the PATH without requiring the\n/// user to install a separate executable, simplifying the deployment of Codex\n/// CLI.\n/// Note: In debug builds the temp-dir guard is disabled to ease local testing.\n///\n/// IMPORTANT: Callers must update PATH before multiple threads are spawned.\nfn prepare_path_entry_for_codex_aliases(\n    existing_path: Option<OsString>,\n) -> std::io::Result<(Arg0PathEntryGuard, OsString)> {\n    let codex_home = find_codex_home()?;\n    #[cfg(not(debug_assertions))]\n    {\n        // Guard against placing helpers in system temp directories outside debug builds.\n        let temp_root = std::env::temp_dir();\n        if codex_home.starts_with(&temp_root) {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                format!(\n                    \"Refusing to create helper binaries under temporary dir {temp_root:?} (codex_home: {codex_home:?})\"\n                ),\n            ));\n        }\n    }\n\n    std::fs::create_dir_all(&codex_home)?;\n    // Use a CODEX_HOME-scoped temp root to avoid cluttering the top-level directory.\n    let temp_root = codex_home.join(\"tmp\").join(\"arg0\");\n    std::fs::create_dir_all(&temp_root)?;\n    #[cfg(unix)]\n    {\n        use std::os::unix::fs::PermissionsExt;\n\n        // Ensure only the current user can access the temp directory.\n        std::fs::set_permissions(&temp_root, std::fs::Permissions::from_mode(0o700))?;","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/arg0/src/lib.rs#L329-L365","documentation":"At startup the codex binary creates arg0-dispatch helper symlinks (apply_patch and friends) under CODEX_HOME. In release builds (cfg(not(debug_assertions))) prepare_path_entry_for_codex_aliases refuses to place those helpers when the resolved codex home lies under std::env::temp_dir(), returning io::ErrorKind::InvalidInput with this message. Helpers in a volatile temp directory would vanish under tmp cleaners and break PATH-based dispatch; the guard is compiled out in debug builds to ease local testing.","triggerScenarios":"Running a release codex binary with CODEX_HOME set to a path under TMPDIR (for example CODEX_HOME=/tmp/codex-home), or TMPDIR redefined to a parent of the resolved home. Common in sandboxes, containers, CI, and test harnesses that isolate state under /tmp.","commonSituations":"CI containers exporting CODEX_HOME=$(mktemp -d); sandboxed dev shells with unusual TMPDIR; wrapper scripts pointing CODEX_HOME at a scratch directory.","solutions":["Point CODEX_HOME at a persistent directory outside the temp root (e.g. $HOME/.codex) and re-run","Unset CODEX_HOME to fall back to the default home directory","If TMPDIR was overridden to cover the home directory, fix TMPDIR instead","Local development only: run a debug build, where the guard is disabled"],"exampleFix":"# before\nexport CODEX_HOME=\"$(mktemp -d)\" # release build refuses: home is under temp dir\n\n# after\nexport CODEX_HOME=\"$HOME/.codex\" # persistent location outside temp_dir()","handlingStrategy":"validation","validationCode":"let codex_home = std::env::var_os(\"CODEX_HOME\")\n    .map(PathBuf::from)\n    .unwrap_or_else(|| default_codex_home());\nif codex_home.starts_with(std::env::temp_dir()) {\n    // pick a persistent home before launching the release binary\n}","typeGuard":null,"tryCatchPattern":"// when spawning codex: match on io::ErrorKind::InvalidInput from startup,\n// re-point CODEX_HOME to a persistent directory, and retry the launch once.","preventionTips":["Never place CODEX_HOME under TMPDIR in release deployments","Bake a stable CODEX_HOME into container images instead of mktemp","Document that release builds refuse temp-dir homes"],"tags":["rust","codex","configuration","environment","startup"],"backgroundTag":"config-dir-in-temp-dir","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}