Egonex-AI/Understand-Anything · error · CliUsageError
--output must be outside the subject repository
Error message
--output must be outside the subject repository
What it means
CliUsageError thrown by parseArgs when the resolved output JSON path is inside (or equal to) the subject repository root. The benchmark intentionally writes all artifacts outside the repo to keep the subject tree clean and to avoid contaminating git metadata/digests used for reproducibility.
Source
Thrown at scripts/lib/large-repo-benchmark.mjs:271
}
const repoRoot = resolve(cwd, repoValue);
if (!existsSync(repoRoot)) {
throw new CliUsageError(`Repository path does not exist: ${repoValue}`);
}
if (!statSync(repoRoot).isDirectory()) {
throw new CliUsageError(`Repository path is not a directory: ${repoValue}`);
}
const outputPath = resolve(cwd, outputValue);
const markdownPath = resolve(
cwd,
outputPath.toLowerCase().endsWith('.json')
? `${outputPath.slice(0, -'.json'.length)}.md`
: `${outputPath}.md`,
);
if (isPathInsideOrEqual(repoRoot, outputPath)) {
throw new CliUsageError('--output must be outside the subject repository');
}
if (isPathInsideOrEqual(repoRoot, markdownPath)) {
throw new CliUsageError('Markdown report path must be outside the subject repository');
}
return {
help: false,
repoRoot,
outputPath,
markdownPath,
label: label || basename(repoRoot),
concurrency,
keepArtifacts,
};
}
export function helpText() {
return `Usage:View on GitHub (pinned to 32944829e7)
Solutions
- Choose an output directory outside the subject repository, e.g. ../reports/out.json.
- Use an absolute path in a separate reports directory.
- Confirm with --help that artifacts must live outside the subject repo.
- If you need the report in the repo later, copy it there after the run completes.
Example fix
# before node benchmark-large-repo.mjs myrepo --output myrepo/out.json # after node benchmark-large-repo.mjs myrepo --output ../reports/out.json
Defensive patterns
Strategy: validation
Validate before calling
import { isPathInsideOrEqual } from './lib/large-repo-benchmark.mjs';
if (isPathInsideOrEqual(repoRoot, resolve(cwd, outputValue))) { /* choose a path outside the repo */ } Try / catch
try { const opts = parseArgs(argv); } catch (e) { if ((e as Error).name === 'CliUsageError') { console.error(e.message); process.exit(2); } throw e; } Prevention
- Always write reports to a directory outside the subject repository.
- Use absolute paths for output to avoid cwd-related surprises.
When it happens
Trigger: Passing --output path/to/report.json where the resolved path falls under repoRoot; pointing output at the repo root itself; using a relative path that resolves into the repo when combined with cwd.
Common situations: Defaulting the output to inside the project for convenience; a relative path that happened to land inside the repo; misunderstanding the requirement that artifacts stay external.
Related errors
- Markdown report path must be outside the subject repository
- Repository path does not exist: ${repoValue}
- Repository path is not a directory: ${repoValue}
- Unable to remove temporary benchmark artifacts
- ${flag} requires a value
AI-assisted analysis of Egonex-AI/Understand-Anything@32944829e7 (2026-08-12).
Data as JSON: /api/errors/e4bfda975be739ac.
Report an issue: GitHub.