{"record":{"id":"bd426fb97a0a7547","repo":"openai/codex","slug":"directory-already-exists","errorCode":null,"errorMessage":"directory already exists","messagePattern":"directory already exists","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/exec-server/src/no_follow/unix.rs","lineNumber":264,"sourceCode":"\nfn unix_time_ms(seconds: i64, nanoseconds: impl TryInto<i64>) -> i64 {\n    let nanoseconds = nanoseconds.try_into().unwrap_or_default();\n    seconds\n        .saturating_mul(1_000)\n        .saturating_add(nanoseconds / 1_000_000)\n}\n\npub(super) async fn metadata(path: PathBuf) -> io::Result<FileMetadata> {\n    tokio::task::spawn_blocking(move || metadata_sync(&path))\n        .await\n        .map_err(|error| io::Error::other(format!(\"filesystem task failed: {error}\")))?\n}\n\npub(super) async fn create_directory(path: PathBuf, recursive: bool) -> io::Result<()> {\n    tokio::task::spawn_blocking(move || {\n        let components = components(&path)?;\n        if components.is_empty() && !recursive {\n            return Err(io::Error::new(\n                io::ErrorKind::AlreadyExists,\n                \"directory already exists\",\n            ));\n        }\n        let mut directory = root()?;\n        for (index, component) in components.iter().enumerate() {\n            let is_leaf = index + 1 == components.len();\n            if !recursive && is_leaf {\n                mkdirat(&directory, component, Mode::from_raw_mode(0o777))\n                    .map_err(io::Error::from)?;\n                return Ok(());\n            }\n            match open_directory(&directory, component) {\n                Ok(next) => directory = next,\n                Err(error) if recursive && error.kind() == io::ErrorKind::NotFound => {\n                    match mkdirat(&directory, component, Mode::from_raw_mode(0o777)) {\n                        Ok(()) | Err(rustix::io::Errno::EXIST) => {}\n                        Err(error) => return Err(io::Error::from(error)),","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/exec-server/src/no_follow/unix.rs#L246-L282","documentation":"Error \"directory already exists\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/exec-server/src/no_follow/unix.rs:264 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}