pbakaus/impeccable · error

embed-prompt: --scan needs at least one directory

Error message

embed-prompt: --scan needs at least one directory

What it means

In `embed-prompt --scan` mode, all non-`--` arguments are treated as directories to rasterize; if none remain after flag filtering, the command prints this prefixed message and exits 1 instead of scanning an empty target set.

Source

Thrown at crates/context/src/embed_prompt.rs:200

    let lower = p.to_ascii_lowercase();
    lower.ends_with(".png") || lower.ends_with(".jpg") || lower.ends_with(".jpeg") || lower.ends_with(".webp")
}

pub fn run(args: &[String], io: &mut Io) -> i32 {
    let cwd = io.cwd.to_string_lossy().into_owned();
    let abs = |p: &str| -> String { jsp::resolve(&cwd, &[p]) };
    let file = args.iter().find(|a| !a.starts_with("--")).cloned();
    let read_mode = args.iter().any(|a| a == "--read");
    let scan_mode = args.iter().any(|a| a == "--scan");
    let arg_of = |name: &str| -> Option<String> {
        let i = args.iter().position(|a| a == name)?;
        args.get(i + 1).cloned()
    };

    if scan_mode {
        let targets: Vec<&String> = args.iter().filter(|a| !a.starts_with("--")).collect();
        if targets.is_empty() {
            io.err("embed-prompt: --scan needs at least one directory\n");
            return 1;
        }
        let mut rasters: Vec<String> = Vec::new();
        for t in &targets {
            if !exists(&abs(t)) {
                io.err(&format!("embed-prompt: no such path {}\n", t));
                return 1;
            }
            // JS walks with the path as given (relative to cwd); output uses that spelling.
            let saved = std::env::current_dir().ok();
            let _ = std::env::set_current_dir(&cwd);
            let r = walk(t, true, &mut rasters);
            if let Some(s) = saved {
                let _ = std::env::set_current_dir(s);
            }
            if let Err(e) = r {
                io.err(&format!("Error: {}\n", e));
                return 1;

View on GitHub (pinned to 2bc2879276)

Solutions

  1. Pass at least one directory after the flags: `embed-prompt --scan <dir> [more-dirs...]`.
  2. Quote and verify the path variable is non-empty before invoking (`echo "$DIR"`).
  3. Ensure the argument does not start with `--`, or it will be filtered out as a flag.
  4. Confirm each given path exists — a subsequent 'no such path' error means the argument was consumed but invalid.

Example fix

# before
DIR=; embed-prompt --scan $DIR
embed-prompt: --scan needs at least one directory
# after
embed-prompt --scan ./src/components
Defensive patterns

Strategy: validation

Validate before calling

const targets = args.filter(a => !a.startsWith('--'));
if (scanMode && targets.length === 0) {
  throw new Error('embed-prompt --scan requires at least one directory');
}

Prevention

When it happens

Trigger: Running `embed-prompt --scan` with no path arguments, or where every argument is a flag (e.g. only `--scan --verbose`), or a shell variable holding the directory expanding to empty.

Common situations: Forgetting the directory argument in a script; a variable like `$DIR` unset so the positional vanishes; quoting errors swallowing the path into a flag value.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of pbakaus/impeccable@2bc2879276 (2026-09-08). Data as JSON: /api/errors/63f86c0118a5e869. Report an issue: GitHub.