pbakaus/impeccable · error · Error
--target requires a path value (use --target <path> or --tar
Error message
--target requires a path value (use --target <path> or --target=<path>)
What it means
Thrown by consumeTargetArg when the live boot sees `--target` as a bare flag with no following path argument (the next token is missing, empty, or itself starts with `--`). The guard exists so a malformed target cannot degrade into implicit 'most recent app' selection, which would silently mutate the wrong app's session state.
Source
Thrown at plugin/skills/impeccable/scripts/live/roots.mjs:451
if (fresh.selection) return { selection: fresh.selection, source: 'fresh' };
return { manifest: fresh.manifest, source: 'fresh' };
}
/**
* Consume a `--target <path>` / `--target=<path>` pair from an argv array,
* returning the value and removing the tokens so downstream flag parsers
* (which do not know the option) never see them.
*/
export function consumeTargetArg(argv = process.argv) {
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
if (arg === '--target') {
const value = argv[i + 1];
// A --target with no usable value must not degrade into implicit root
// selection: these helpers mutate session state, and "the most recent
// app" is exactly what the caller was trying NOT to get.
if (typeof value !== 'string' || value === '' || value.startsWith('--')) {
throw new Error('--target requires a path value (use --target <path> or --target=<path>)');
}
argv.splice(i, 2);
return value;
}
if (typeof arg === 'string' && arg.startsWith('--target=')) {
const value = arg.slice('--target='.length);
if (value === '') {
throw new Error('--target requires a path value (use --target <path> or --target=<path>)');
}
argv.splice(i, 1);
return value;
}
}
return null;
}
/**
* Entry-point guard for live CLI scripts: resolve the governing roots andView on GitHub (pinned to d14711ae3d)
Solutions
- Provide the path right after: `--target ./apps/web` or use the equals form `--target=./apps/web`.
- Check your wrapper script for cases where the target path variable is empty before appending --target.
- Run the helper without --target to fall back to implicit root resolution if multi-app disambiguation is not needed.
Example fix
# before node helper.mjs --target # after node helper.mjs --target ./apps/web
Defensive patterns
Strategy: validation
Validate before calling
function validateTargetArg(argv) {
const idx = argv.indexOf('--target');
if (idx === -1) return null;
const value = argv[idx + 1];
if (typeof value !== 'string' || value === '' || value.startsWith('--')) {
throw new Error('--target needs a path');
}
return value;
} Type guard
function isValidTargetValue(value) {
return typeof value === 'string' && value.length > 0 && !value.startsWith('--');
} Try / catch
try {
consumeTargetArg(process.argv);
} catch (err) {
console.error(err.message);
process.exit(1);
} Prevention
- Always pair --target with its path in wrapper scripts, never append it conditionally.
- Prefer the --target=path form to avoid ambiguity with following flags.
- Test CLI wrappers with an unset target variable to confirm they degrade safely.
When it happens
Trigger: Invoking a live helper with `--target` at the end of argv, `--target --port 4321`, or `--target ""`. The throw fires from the space-separated form branch before argv mutation.
Common situations: Shell quoting mistake, a typo where another flag follows --target, or a script that conditionally appends --target but forgets the value.
Related errors
- Unknown argument: ${arg}
- --warning-days must be a non-negative number.
- --close-days must be at least --warning-days.
- --now must be a valid date.
- ${flag} requires a value.
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/f7d30942f87dbb87.
Report an issue: GitHub.