{"record":{"id":"7a770bb50769b3b2","repo":"Kuberwastaken/claurst","slug":"failed-to-install-new-binary","errorCode":null,"errorMessage":"failed to install new binary: {}","messagePattern":"failed to install new binary: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/cli/src/upgrade.rs","lineNumber":371,"sourceCode":"    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\n        // it but not unlink it, so move-aside, then move-in-place.\n        let mut sidelined = current.to_path_buf();\n        sidelined.set_extension(\"exe.old\");\n        let _ = std::fs::remove_file(&sidelined);\n        std::fs::rename(current, &sidelined)\n            .with_context(|| format!(\"failed to sideline current exe to {}\", sidelined.display()))?;\n        if let Err(e) = std::fs::copy(new, current) {\n            // Try to roll back the rename so the user isn't left without claurst.\n            let _ = std::fs::rename(&sidelined, current);\n            bail!(\"failed to install new binary: {}\", e);\n        }\n        // Best-effort cleanup of the old exe (Windows may keep it locked\n        // until the running process exits — that's fine).\n        let _ = std::fs::remove_file(&sidelined);\n        Ok(())\n    }\n\n    #[cfg(unix)]\n    {\n        use std::io::Write;\n        use std::os::unix::fs::PermissionsExt;\n\n        // std::fs::copy() writes into the existing inode (open + O_TRUNC), and\n        // that inode is the running process's own text segment — the kernel\n        // rejects the write with ETXTBSY (\"Text file busy\"). rename() instead\n        // swaps the directory entry to point at a new inode, which the kernel\n        // allows even while the old inode is still mapped and executing.\n        // rename() requires src/dest on the same filesystem, so stage the","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/cli/src/upgrade.rs#L353-L389","documentation":"The in-place binary replacement failed: renaming/moving the new binary into the current executable's path errored (the formatted value is the underlying io error). On Windows the running exe must be sidelined first; failure typically means the file is locked by a running instance or the directory denies writes.","triggerScenarios":"Thrown at src-rust/crates/cli/src/upgrade.rs:371 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Close all running claurst instances and retry the upgrade","Check write permissions on the install directory (may need elevated privileges)","Delete leftover .exe.old / staging files that may block the rename, then re-run"],"exampleFix":null,"handlingStrategy":"fallback","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"}