{"record":{"id":"159f0b69180909b3","repo":"Kuberwastaken/claurst","slug":"failed-to-create-a-unique-upgrade-staging-file-nex","errorCode":null,"errorMessage":"failed to create a unique upgrade staging file next to {} after {} attempts","messagePattern":"failed to create a unique upgrade staging file next to (.+?) after (.+?) attempts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/cli/src/upgrade.rs","lineNumber":343,"sourceCode":"            staged_name.push(file_name);\n            staged_name.push(format!(\".upgrade-{}-{}\", std::process::id(), id));\n            let path = parent.join(staged_name);\n\n            match OpenOptions::new().write(true).create_new(true).open(&path) {\n                Ok(file) => return Ok((Self { path }, file)),\n                Err(error) if error.kind() == ErrorKind::AlreadyExists => continue,\n                Err(error) => {\n                    return Err(error).with_context(|| {\n                        format!(\n                            \"failed to create upgrade staging file next to {}\",\n                            current.display()\n                        )\n                    });\n                }\n            }\n        }\n\n        bail!(\n            \"failed to create a unique upgrade staging file next to {} after {} attempts\",\n            current.display(),\n            MAX_ATTEMPTS\n        )\n    }\n}\n\n#[cfg(unix)]\nimpl Drop for StagedBinary {\n    fn drop(&mut self) {\n        let _ = std::fs::remove_file(&self.path);\n    }\n}\n\nfn swap_binary(current: &Path, new: &Path) -> Result<()> {\n    #[cfg(target_os = \"windows\")]\n    {\n        // Windows holds an exclusive lock on the running .exe — we can rename","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/cli/src/upgrade.rs#L325-L361","documentation":"The upgrade staging routine tried to create a uniquely-named temporary file (`.upgrade-<pid>-<n>`) next to the current binary, but every attempt collided with an already-existing file until the attempt budget ran out. The formatted values are the parent directory and attempt count. Usually means many stale staging files litter the binary's directory.","triggerScenarios":"Thrown at src-rust/crates/cli/src/upgrade.rs:343 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete stale `.upgrade-*` files from the binary's directory and retry","Check the directory is writable and not full","Retry the upgrade — the names include the PID so a fresh run usually picks a free slot"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}