{"record":{"id":"d82a4ed2b811b657","repo":"rust-lang/rust-analyzer","slug":"error-creating-directory-path-e","errorCode":null,"errorMessage":"error creating directory {path:?}: {e}","messagePattern":"error creating directory (.+?): (.+?)","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/stdx/src/tempfile.rs","lineNumber":98,"sourceCode":"    static INTERNAL_COUNTER: AtomicU32 = AtomicU32::new(0);\n\n    pub(super) fn create<T>(\n        prefix: &str,\n        mut create: impl FnMut(OpenOptions, &Path) -> io::Result<T>,\n    ) -> io::Result<(T, PathBuf)> {\n        let temp_dir = std::env::temp_dir().canonicalize()?;\n        let pid = std::process::id();\n        loop {\n            let path = temp_dir.join(format!(\n                \"{prefix}{pid:x}-{:x}\",\n                INTERNAL_COUNTER.fetch_add(1, Ordering::AcqRel),\n            ));\n            let mut open_options = OpenOptions::new();\n            open_options.create_new(true);\n            match create(open_options, &path) {\n                Err(e) if e.kind() == ErrorKind::AlreadyExists => {}\n                Err(e) => {\n                    return Err(io::Error::new(\n                        e.kind(),\n                        format!(\"error creating directory {path:?}: {e}\"),\n                    ));\n                }\n                Ok(file) => {\n                    return Ok((file, path));\n                }\n            }\n        }\n    }\n}\n\n#[cfg(any(\n    target_os = \"linux\",\n    target_os = \"freebsd\",\n    target_os = \"openbsd\",\n    target_os = \"netbsd\",\n))]","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/stdx/src/tempfile.rs#L80-L116","documentation":"An `io::Error` formatting string in `stdx`'s tempfile helper `create`: the loop joins a prefix, PID, and an internal atomic counter into a candidate path and calls the caller's `create` with `create_new(true)`; when the create callback fails for a non-collision reason, the error is wrapped with the candidate `{path}`. The input at fault is the OS-level directory/file creation under the system temp dir (permissions, disk full, or the specific callback's open options).","triggerScenarios":"Thrown at crates/stdx/src/tempfile.rs:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the system temp dir (`std::env::temp_dir`) is writable and not full","If the failure is `AlreadyExists` from a non-atomic helper, the retry loop only covers collisions produced by this helper — ensure custom create callbacks use `create_new(true)` so the loop can retry on collision","Clear stale temp files matching the prefix that may block creation","Surface the underlying `e` in the message to identify the exact OS error kind"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}