Hmbown/CodeWhale · error · Error
Output directory must be empty
Error message
Output directory must be empty: ${outputDirectory} What it means
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.
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.
Example fix
// before node assemble-release-assets.js --out ./release # already populated // after rm -rf ./release && node assemble-release-assets.js --out ./release
Defensive patterns
Strategy: validation
Validate before calling
const existing = await fs.readdir(outputDir).catch(() => []);
if (existing.length > 0) throw new Error(`output dir not empty: ${outputDir}`); Try / catch
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; } Prevention
- 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.
When it happens
Trigger: Re-running assemble without cleaning the output directory from a previous run, or pointing --output at a directory that already holds other files.
Common situations: Local retry after a failed assembly, a CI cache restoring an old output directory, or pointing the script at a shared release folder.
Related errors
- could not read Cargo metadata
- Downloaded release artifact must be a regular file
- Release asset directory must be flat; found
- already exists; pass --force to overwrite it
- AlreadyExists
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/604e4106c3f93dd8.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/release/assemble-release-assets.js:143
let sourceStat;
try {
sourceStat = await fs.lstat(source);
} catch (error) {
if (error && error.code === "ENOENT") {
throw new Error(`Downloaded release artifacts are missing ${name} at ${source}`);
}
throw error;
}
if (!sourceStat.isFile()) {
throw new Error(`Downloaded release artifact must be a regular file: ${source}`);
}
sources.set(name, source);
}
await fs.mkdir(outputDirectory, { recursive: true });
const existing = await fs.readdir(outputDirectory);
if (existing.length > 0) {
throw new Error(`Output directory must be empty: ${outputDirectory}`);
}
for (const name of copiedNames) {
await fs.copyFile(sources.get(name), path.join(outputDirectory, name));
}
await fs.writeFile(
path.join(outputDirectory, WINDOWS_LAUNCHER),
windowsLauncherContents(),
"utf8",
);
const checksumRows = [];
for (const name of [...checksummedReleaseAssetNames()].sort()) {
checksumRows.push(`${await sha256(path.join(outputDirectory, name))} ${name}`);
}
await fs.writeFile(
path.join(outputDirectory, CHECKSUM_MANIFEST),
`${checksumRows.join("\n")}\n`,View on GitHub (pinned to 433685b202)