n8n-io/n8n · error · Error
--build-cwd directory does not exist: ${args.buildCwd}
Error message
--build-cwd directory does not exist: ${args.buildCwd} What it means
The --build-cwd flag sets the working directory for the build subprocess (where claude -p runs), letting the user spawn the builder from a project where they have Claude skills/settings configured. main() (line 461) checks existsSync(args.buildCwd) and throws if the directory does not exist, preventing the subprocess from failing later with a less informative error.
Source
Thrown at packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts:462
execSync('command -v claude', { stdio: 'ignore' });
} catch {
throw new Error('claude not on PATH');
}
// Repo root scopes the staged MCP config (cwd fallback). Best-effort: the disk
// source resolves/validates its own test-case dir below; langtracer pulls cases
// over MCP, so it needs no repo at all and can run outside the n8n checkout.
let repoRoot: string | undefined;
try {
repoRoot = execSync('git rev-parse --show-toplevel', { stdio: ['ignore', 'pipe', 'ignore'] })
.toString()
.trim();
} catch {
repoRoot = undefined;
}
if (args.buildCwd && !existsSync(args.buildCwd)) {
throw new Error(`--build-cwd directory does not exist: ${args.buildCwd}`);
}
// Resolve slug -> conversation from the chosen source. Disk reads --workflow-dir
// (positional slugs or discovered), langtracer pulls a suite over MCP; both feed
// the same buildOne prompt.
const casesBySlug = new Map<string, ConversationTurn[]>();
if (args.source === 'langtracer') {
const suite = args.suite;
if (!suite) throw new Error('--source langtracer requires --suite <slug>');
const cases = await loadTestCasesFromLangTracer({
suite,
tier: args.tier,
logger: createLogger(false),
});
for (const { fileSlug, testCase } of cases)
casesBySlug.set(fileSlug, testCase.conversation ?? []);
if (args.slugs.length > 0) {
const requested = new Set(args.slugs);View on GitHub (pinned to 5ac6606e81)
Solutions
- Verify the directory exists: ls <path>
- Use an absolute path to avoid ambiguity with the current working directory
- Create the directory if needed: mkdir -p <path>
- Omit --build-cwd to use the default (repo root when inside the repo, otherwise process.cwd())
Example fix
# before pnpm eval:build-mcp-manifest --build-cwd ~/projects/wrong # after pnpm eval:build-mcp-manifest --build-cwd ~/projects/correct
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs';
if (args.buildCwd && !existsSync(args.buildCwd)) {
throw new Error(`--build-cwd directory does not exist: ${args.buildCwd}`);
} Prevention
- Use absolute paths for --build-cwd
- Verify the directory exists with ls before running
- Omit --build-cwd if you do not need a custom build working directory
When it happens
Trigger: Running `pnpm eval:build-mcp-manifest --build-cwd /nonexistent/path`. The check fires after git repo-root resolution but before any build work begins.
Common situations: Typo in the path. The directory was deleted or not yet created. A relative path resolved against an unexpected working directory.
Related errors
- Workflow directory not found: ${workflowDir}
- Disk source needs the n8n repo (run from inside it) or --wor
- --max-attempts must be >= 1
- --source langtracer requires --suite <slug>
- Failed to parse ${label} at ${path}: ${msg}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/1f005d2bba075eda.
Report an issue: GitHub.