openai/codex-plugin-cc · error · Error
--root requires a directory.
Error message
--root requires a directory.
What it means
Thrown by parseArgs() in bump-version.mjs when the --root flag is the last token on the command line with no value following it. The parser reads argv[i+1] and requires it to be truthy; a missing directory argument is rejected before path resolution.
Source
Thrown at scripts/bump-version.mjs:103
].join("\n");
}
function parseArgs(argv) {
const options = {
check: false,
root: process.cwd(),
version: null
};
for (let i = 0; i < argv.length; i += 1) {
const arg = argv[i];
if (arg === "--check") {
options.check = true;
} else if (arg === "--root") {
const root = argv[i + 1];
if (!root) {
throw new Error("--root requires a directory.");
}
options.root = root;
i += 1;
} else if (arg === "--help" || arg === "-h") {
options.help = true;
} else if (arg.startsWith("-")) {
throw new Error(`Unknown option: ${arg}`);
} else if (options.version) {
throw new Error(`Unexpected extra argument: ${arg}`);
} else {
options.version = arg;
}
}
options.root = path.resolve(options.root);
return options;
}
View on GitHub (pinned to db52e28f4d)
Solutions
- Supply a directory after --root: `node scripts/bump-version.mjs --root /path/to/repo 1.0.0`.
- If you meant the current directory, pass `.` explicitly: --root .
- In wrapper scripts, guard that the root value is set before appending the flag.
Example fix
// before $ node scripts/bump-version.mjs --root // after $ node scripts/bump-version.mjs --root . 1.0.0
Defensive patterns
Strategy: validation
Validate before calling
function parseBumpArgs(argv) {
const i = argv.indexOf("--root");
if (i !== -1 && (i === argv.length - 1 || argv[i + 1].startsWith("-"))) {
throw new Error("--root requires a directory argument.");
}
// ...then delegate to the real parser
} Prevention
- Always pair --root with an explicit path (use '.' for cwd).
- In wrapper scripts, assert the root value is non-empty before appending the flag.
- Use --help to confirm flag syntax before first run.
When it happens
Trigger: Running `node scripts/bump-version.mjs --root` (flag at end) or `... --root --check` (next token is another flag, though note the parser only checks truthiness, so a following flag would actually be consumed — the real trigger is --root as the final arg). The strict trigger is: argv[i]==='--root' and argv[i+1] is undefined.
Common situations: Shell quoting accident truncating the path; a copy-pasted command missing the directory; script wrapper that conditionally appends --root but omits the value.
Related errors
- Unknown option: ${arg}
- Unexpected extra argument: ${arg}
- Expected a semver-like version such as 1.0.3, got: ${version
- Missing version.\n\n${usage()}
- Unsupported reasoning effort "${effort}". Use one of: none,
AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13).
Data as JSON: /api/errors/c5c8f10483770218.
Report an issue: GitHub.