{"record":{"id":"604e4106c3f93dd8","repo":"Hmbown/CodeWhale","slug":"output-directory-must-be-empty-outputdirectory","errorCode":null,"errorMessage":"Output directory must be empty: ${outputDirectory}","messagePattern":"Output directory must be empty: (.+?)","errorType":"console","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/release/assemble-release-assets.js","lineNumber":143,"sourceCode":"    let sourceStat;\n    try {\n      sourceStat = await fs.lstat(source);\n    } catch (error) {\n      if (error && error.code === \"ENOENT\") {\n        throw new Error(`Downloaded release artifacts are missing ${name} at ${source}`);\n      }\n      throw error;\n    }\n    if (!sourceStat.isFile()) {\n      throw new Error(`Downloaded release artifact must be a regular file: ${source}`);\n    }\n    sources.set(name, source);\n  }\n\n  await fs.mkdir(outputDirectory, { recursive: true });\n  const existing = await fs.readdir(outputDirectory);\n  if (existing.length > 0) {\n    throw new Error(`Output directory must be empty: ${outputDirectory}`);\n  }\n\n  for (const name of copiedNames) {\n    await fs.copyFile(sources.get(name), path.join(outputDirectory, name));\n  }\n  await fs.writeFile(\n    path.join(outputDirectory, WINDOWS_LAUNCHER),\n    windowsLauncherContents(),\n    \"utf8\",\n  );\n\n  const checksumRows = [];\n  for (const name of [...checksummedReleaseAssetNames()].sort()) {\n    checksumRows.push(`${await sha256(path.join(outputDirectory, name))}  ${name}`);\n  }\n  await fs.writeFile(\n    path.join(outputDirectory, CHECKSUM_MANIFEST),\n    `${checksumRows.join(\"\\n\")}\\n`,","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/release/assemble-release-assets.js#L125-L161","documentation":"assemble creates the output directory (recursively) and then requires it to be empty before copying assets. If readdir finds any pre-existing entries, it throws this Error rather than overwriting or mixing with stale content.","triggerScenarios":"Re-running assemble without cleaning the output directory from a previous run, or pointing --output at a directory that already holds other files.","commonSituations":"Local retry after a failed assembly, a CI cache restoring an old output directory, or pointing the script at a shared release folder.","solutions":["Delete the output directory's contents (or the directory itself) and re-run assemble.","Pass a fresh --output path for each assembly run.","Clear the CI cache or add a cleanup step before the assemble job."],"exampleFix":"// before\nnode assemble-release-assets.js --out ./release  # already populated\n// after\nrm -rf ./release && node assemble-release-assets.js --out ./release","handlingStrategy":"validation","validationCode":"const existing = await fs.readdir(outputDir).catch(() => []);\nif (existing.length > 0) throw new Error(`output dir not empty: ${outputDir}`);","typeGuard":null,"tryCatchPattern":"try { await assemble(...); } catch (e) { if (String(e.message).startsWith('Output directory must be empty')) { console.error('Clean the output dir first:', e.message); process.exitCode = 1; } else throw e; }","preventionTips":["rm -rf the output directory before each assembly run.","Use a unique output path per run.","Disable CI caching of the output directory or clear it in a pre-step."],"tags":["release","filesystem","idempotency"],"backgroundTag":"directory-not-found","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}