affaan-m/ECC · error · Error
--write requires a path
Error message
--write requires a path
What it means
The --write flag for scripts/ci/supply-chain-advisory-sources.js expects a file path argument immediately after it. The parser uses argv[++i] to consume the next token, and if that token is undefined (i.e., --write is the last argument on the command line) the script throws this error. This is a hard guard before writeReport() is ever called, ensuring fs.writeFileSync always receives a real path.
Source
Thrown at scripts/ci/supply-chain-advisory-sources.js:391
if (arg === '--help' || arg === '-h') {
options.help = true;
} else if (arg === '--json') {
options.json = true;
} else if (arg === '--refresh') {
options.refresh = true;
} else if (arg === '--strict-refresh') {
options.strictRefresh = true;
options.refresh = true;
} else if (arg === '--generated-at') {
options.generatedAt = argv[++i];
} else if (arg === '--timeout-ms') {
options.timeoutMs = Number(argv[++i]);
if (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0) {
throw new Error('--timeout-ms must be a positive number');
}
} else if (arg === '--write') {
options.writePath = argv[++i];
if (!options.writePath) throw new Error('--write requires a path');
} else {
throw new Error(`Unknown argument: ${arg}`);
}
}
return options;
}
function printHelp() {
console.log(`Usage: node scripts/ci/supply-chain-advisory-sources.js [options]
Build the active supply-chain advisory source report used by the scheduled
watch workflow and Linear ITO-57 status updates.
Options:
--json Emit JSON instead of text
--refresh Check source URLs and record warning status
--strict-refresh Fail when a refreshed source URL returns a warning
--generated-at <ts> Override the report timestampView on GitHub (pinned to 01e15490f0)
Solutions
- Provide a file path immediately after --write, e.g. --write reports/advisory-sources.json
- If building the command dynamically, ensure the path variable is non-empty before appending --write
- Run the script with --help to see all expected flag-value pairs
Example fix
// before node scripts/ci/supply-chain-advisory-sources.js --write // after node scripts/ci/supply-chain-advisory-sources.js --write reports/advisory-sources.json
Defensive patterns
Strategy: validation
Validate before calling
// Before calling parseArgs, validate that --write has a companion path
const argv = process.argv.slice(2);
const writeIdx = argv.indexOf('--write');
if (writeIdx !== -1 && (!argv[writeIdx + 1] || argv[writeIdx + 1].startsWith('--'))) {
console.error('Error: --write requires a file path argument');
process.exit(1);
} Try / catch
// Wrap the script invocation and catch argument errors with user-friendly messages
try {
const options = parseArgs(process.argv.slice(2));
} catch (error) {
if (error.message.includes('requires a path')) {
console.error('Missing file path for --write. Usage: --write <file-path>');
printHelp();
process.exit(2);
}
throw error;
} Prevention
- Always provide a file path immediately after --write in the same command
- In CI YAML, use a named variable for the path and verify it is non-empty before appending --write
- Run the script with --help first to confirm expected flag-value pairs
When it happens
Trigger: Running `node scripts/ci/supply-chain-advisory-sources.js --write` with no path after the flag, or placing --write at the end of the command line. Also triggered if --write is followed by nothing because the shell consumed the next token as a separate command.
Common situations: CI YAML or workflow file that appends --write conditionally but forgets the path variable; shell scripts that build the argument list dynamically and skip the path; copy-pasting a partial command from documentation without completing the path.
Related errors
- Unknown argument: ${arg}
- Unknown argument: ${arg}
- --timeout-ms must be a positive number
- Unknown argument: ${arg}
- Invalid ${flag}: expected a single cache path segment
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/9e9b1d0023f901a1.
Report an issue: GitHub.