paperclipai/paperclip · error · Error
Output directory already exists and is not empty: ${outputDi
Error message
Output directory already exists and is not empty: ${outputDir} What it means
ensureEmptyOutputDirectory throws when the target path is an existing directory that already contains entries, to prevent silently merging new export files with old content.
Source
Thrown at cli/src/commands/client/feedback.ts:563
function padRight(value: string, width: number): string {
return `${value}${" ".repeat(Math.max(0, width - value.length))}`;
}
function defaultFeedbackExportDirName(): string {
const iso = new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
return `feedback-export-${iso}`;
}
async function ensureEmptyOutputDirectory(outputDir: string): Promise<void> {
try {
const info = await stat(outputDir);
if (!info.isDirectory()) {
throw new Error(`Output path already exists and is not a directory: ${outputDir}`);
}
const entries = await readdir(outputDir);
if (entries.length > 0) {
throw new Error(`Output directory already exists and is not empty: ${outputDir}`);
}
} catch (error) {
const message = error instanceof Error ? error.message : "";
if (/ENOENT/.test(message)) {
await mkdir(outputDir, { recursive: true });
return;
}
throw error;
}
}
async function collectJsonFilesForArchive(
outputDir: string,
relativePaths: string[],
): Promise<Record<string, string>> {
const files: Record<string, string> = {};
for (const relativePath of relativePaths) {
const normalized = relativePath.replace(/\\/g, "/");View on GitHub (pinned to 67001ec6eb)
Solutions
- Empty or remove the existing directory first.
- Choose a new --output path.
- Omit --output to get a fresh timestamped default directory.
Example fix
// before paperclipai feedback trace export --output ./traces // after rm -rf ./traces && paperclipai feedback trace export --output ./traces
Defensive patterns
Strategy: validation
Validate before calling
import {readdir} from 'node:fs/promises';
const entries = await readdir(outputDir);
if (entries.length > 0) throw new Error(`Output directory already exists and is not empty: ${outputDir}`); Prevention
- Use a fresh --output per run or omit it for a timestamped default.
- Clean export directories in CI between runs.
When it happens
Trigger: Passing --output <dir> where <dir> exists and is non-empty.
Common situations: Re-running an export into the same directory; pointing --output at a project folder.
Related errors
- Output path already exists and is not a directory: ${outputD
- Could not locate local Paperclip skills directory. Expected
- Export output path ${root} exists and is not a directory.
- Export output directory ${root} already contains files. Re-r
- Company ID is required. Pass --company-id, set PAPERCLIP_COM
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/a9c1ad5d516d057b.
Report an issue: GitHub.