pbakaus/impeccable · 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() in live/roots.mjs when '--target' appears on the helper command line but the next token is not a usable path value. The guard explicitly refuses to fall back to implicit root selection, because these helpers mutate session state and 'most recent app' is precisely what the caller wanted to avoid. The check fails when the value is missing (end of args), empty, or itself starts with '--' (i.e. the next flag was mistaken for a path).

Source

Thrown at skill/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 and

View on GitHub (pinned to d14711ae3d)

Solutions

  1. Provide a concrete path right after --target: '... --target ./apps/web'.
  2. Use the equals form to avoid ambiguity: '--target=./apps/web'.
  3. If the path comes from a variable, default it first: TARGET=${TARGET:-./apps/web}.

Example fix

# before
node live-inject.mjs --target --comment-syntax html
# after
node live-inject.mjs --target ./apps/web --comment-syntax html
Defensive patterns

Strategy: validation

Validate before calling

const idx = argv.indexOf('--target');
if (idx !== -1) {
  const v = argv[idx + 1];
  if (typeof v !== 'string' || v === '' || v.startsWith('--')) {
    throw new Error('provide a path: --target ./apps/web');
  }
}

Prevention

When it happens

Trigger: A live helper CLI is invoked as '--target' with no following token, '--target --foo' (next arg is another flag), or '--target' as the last argument. consumeTargetArg would otherwise silently splice nothing and let root selection degrade.

Common situations: User typed '--target' then hit enter before the path; shell quoting dropped an empty value (--target ''); the path was a variable that expanded to empty (TARGET= node ... --target $TARGET); user intended '--target=somepath' form but wrote space-separated with a missing value.

Related errors


AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13). Data as JSON: /api/errors/aeccb7d4c798d70e. Report an issue: GitHub.