yamadashy/repomix · error · RepomixError
Failed to copy output file: ${(error as Error).message}
Error message
Failed to copy output file: ${(error as Error).message} What it means
Fallback error in `copyOutputToCurrentDirectory`: any copy failure that is not EPERM/EACCES (e.g. ENOSPC disk full, EISDIR, ENOENT) is wrapped into a RepomixError carrying the underlying Node error message. It signals the packed output file could not be moved to the requested target path.
Source
Thrown at src/cli/actions/remoteAction.ts:322
await fs.copyFile(sourcePath, targetPath);
} catch (error) {
const nodeError = error as NodeJS.ErrnoException;
// Provide helpful message for permission errors
if (nodeError.code === 'EPERM' || nodeError.code === 'EACCES') {
throw new RepomixError(
`Failed to copy output file to ${targetPath}: Permission denied.
The current directory may be protected or require elevated permissions.
Please try one of the following:
• Run from a different directory (e.g., your home directory or Documents folder)
• Use the --output flag to specify a writable location: --output ~/repomix-output.xml
• Use --stdout to print output directly to the console`,
);
}
throw new RepomixError(`Failed to copy output file: ${(error as Error).message}`);
}
};
View on GitHub (pinned to f465ad9093)
Solutions
- Read the inner message to identify the errno code and address it
- If `--output` points to a directory, change it to a file path
- Free disk space if the message indicates ENOSPC
- Retry if a transient file lock (AV/indexer) was holding the target
Example fix
// before repomix --remote user/repo --output ./out-dir // after repomix --remote user/repo --output ./out-dir/repomix-output.xml
Defensive patterns
Strategy: try-catch
Validate before calling
const target = path.resolve(outPath);
if (await stat(target).then(s => s.isDirectory(), () => false)) {
throw new Error('--output must be a file path, not a directory');
} Type guard
const isErrno = (e: unknown): e is NodeJS.ErrnoException => e instanceof Error && typeof (e as any).code === 'string';
Try / catch
try {
await runRepomix({ remote: url, output: outPath });
} catch (e) {
if (e instanceof RepomixError && e.message.startsWith('Failed to copy output file:')) {
console.error(e.message); // includes underlying errno (ENOSPC, EISDIR, ...)
}
throw e;
} Prevention
- Ensure `--output` is a file path, not an existing directory
- Keep sufficient free disk space before packing large repos
- Exclude the output path from AV/backup lockers or retry on transient locks
When it happens
Trigger: `fs.copyFile(sourcePath, targetPath)` in `copyOutputToCurrentDirectory` (via `runRemoteAction`) rejects with any errno code other than EPERM/EACCES — e.g. target is a directory (EISDIR), disk full (ENOSPC), source vanished (ENOENT).
Common situations: Passing `--output` pointing to an existing directory name, a full disk during a large pack, or antivirus/backup tooling locking the destination file on Windows.
Related errors
- Failed to copy output file to ${targetPath}: Permission deni
- Refusing to trust ${configName}: the remote repository's con
- Refusing to trust ${configName}: it resolves outside the clo
- Could not read the remote repository's config (${configName}
- Skill output path exists but is not a directory: ${skillDir}
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/8f40d09d8299c0b1.
Report an issue: GitHub.