From b6db6a163f4caa842d2777883a8cd5077b14e7da Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Fri, 31 Jul 2026 17:18:41 +0200 Subject: [PATCH] fix(desktop): unlink destination before copying binaries (#10705) --- AGENTS.md | 1 + ui/desktop/scripts/prepare-platform-binaries.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 3ebf1c550..c5b6c7925 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -106,6 +106,7 @@ ui/desktop/ # Electron app - Never: Skip cargo fmt - Never: Merge without running clippy - Never: Comment self-evident operations (`// Initialize`, `// Return result`), getters/setters, constructors, or standard Rust idioms +- Never: Overwrite a live binary in place (e.g. `cp`/`fs.copyFileSync` onto an existing executable) - unlink or atomic-rename the destination first, otherwise macOS SIGKILLs running processes with "Code Signature Invalid" ## Entry Points - CLI: crates/goose-cli/src/main.rs diff --git a/ui/desktop/scripts/prepare-platform-binaries.js b/ui/desktop/scripts/prepare-platform-binaries.js index 5f698bcc9..cf5b714da 100644 --- a/ui/desktop/scripts/prepare-platform-binaries.js +++ b/ui/desktop/scripts/prepare-platform-binaries.js @@ -140,7 +140,9 @@ async function ensureWindowsUvBinaries() { ); } - fs.copyFileSync(extractedPath, path.join(srcBinDir, name)); + const destPath = path.join(srcBinDir, name); + fs.rmSync(destPath, { force: true }); + fs.copyFileSync(extractedPath, destPath); console.log(`Copied pinned ${name}`); } } finally { @@ -225,9 +227,11 @@ async function copyPlatformFiles(targetPlatform) { const destPath = path.join(srcBinDir, file.name); if (file.isDirectory()) { - fs.cpSync(srcPath, destPath, { recursive: true, force: true }); + fs.rmSync(destPath, { recursive: true, force: true }); + fs.cpSync(srcPath, destPath, { recursive: true }); console.log(`Copied directory: ${file.name}`); } else { + fs.rmSync(destPath, { force: true }); fs.copyFileSync(srcPath, destPath); console.log(`Copied: ${file.name}`); }