{"record":{"id":"c4f4e8abfe92d949","repo":"sinelaw/fresh","slug":"could-not-delete-archive-file","errorCode":null,"errorMessage":"Could not delete archive file:","messagePattern":"Could not delete archive file:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/fresh-editor/npm-package/binary-install.js","lineNumber":145,"sourceCode":"                            fs.renameSync(srcPath, destPath);\n                        }\n                        fs.rmdirSync(nested);\n                    }\n                }\n            }\n        });\n    } catch (error) {\n        error.message = `Extraction failed after retries: ${error.message}. Archive: ${archivePath}`;\n        throw error;\n    }\n\n    // Cleanup archive file\n    try {\n        if (fs.existsSync(archivePath)) {\n            fs.unlinkSync(archivePath);\n        }\n    } catch (e) {\n        console.warn('Could not delete archive file:', e.message);\n    }\n\n    // Verify binary exists\n    if (!fs.existsSync(binaryPath)) {\n        throw new Error(`Installation failed: binary not found at ${binaryPath}. Please check the release assets.`);\n    }\n\n    // Provenance receipt (sidecar next to the binary). Overrides the generic\n    // `tarball` receipt that ships inside the archive so the editor defers\n    // updates to npm rather than self-swapping.\n    try {\n        const receipt = [\n            'schema = 1',\n            'channel = \"npm\"',\n            `version = \"${VERSION}\"`,\n            'package_name = \"fresh-editor\"',\n            'managed = true',\n            'self_update = false',","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/npm-package/binary-install.js#L127-L163","documentation":"In the npm package's binary-install.js install() function, after extraction the code tries to unlink the downloaded archive; if fs.unlinkSync throws (and the file still exists), it logs 'Could not delete archive file:' via console.warn. It is a non-fatal cleanup warning — installation proceeds to verify the binary — but indicates a filesystem problem with the temp archive.","triggerScenarios":"fs.existsSync(archivePath) is true but unlinkSync fails: file locked by another process (Windows AV scanners), read-only filesystem, or permission mismatch on the temp/archive path.","commonSituations":"npm postinstall running on Windows while antivirus holds the freshly downloaded archive open; installing into a read-only mounted volume or globally without write permission to the archive location; disk-full conditions.","solutions":["Treat as a warning: verify the binary actually installed; delete the leftover archive manually.","Check permissions on the directory holding archivePath and ensure the install runs as a user with write access.","Exclude the npm cache/temp directory from antivirus real-time scanning (common on Windows).","Re-run npm install after closing processes that may lock the file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (fs.existsSync(archivePath) && (fs.statSync(archivePath).mode & 0o200) === 0) {\n  fs.chmodSync(archivePath, 0o644);\n}","typeGuard":null,"tryCatchPattern":"try { install(); } catch (e) { if (String(e.message).includes('Could not delete archive')) { fs.rmSync(archivePath, { force: true }); install(); } else throw e; }","preventionTips":["Exclude npm temp dirs from antivirus scanning (Windows).","Install with a user that has write access to the npm cache and global prefix.","Manually delete stale archives in the package temp dir after a failed install."],"tags":["npm","filesystem","cleanup","postinstall"],"backgroundTag":"file-write-failed","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}