{"record":{"id":"63f86c0118a5e869","repo":"pbakaus/impeccable","slug":"embed-prompt-scan-needs-at-least-one-directory","errorCode":null,"errorMessage":"embed-prompt: --scan needs at least one directory\n","messagePattern":"embed-prompt: --scan needs at least one directory\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/embed_prompt.rs","lineNumber":200,"sourceCode":"    let lower = p.to_ascii_lowercase();\n    lower.ends_with(\".png\") || lower.ends_with(\".jpg\") || lower.ends_with(\".jpeg\") || lower.ends_with(\".webp\")\n}\n\npub fn run(args: &[String], io: &mut Io) -> i32 {\n    let cwd = io.cwd.to_string_lossy().into_owned();\n    let abs = |p: &str| -> String { jsp::resolve(&cwd, &[p]) };\n    let file = args.iter().find(|a| !a.starts_with(\"--\")).cloned();\n    let read_mode = args.iter().any(|a| a == \"--read\");\n    let scan_mode = args.iter().any(|a| a == \"--scan\");\n    let arg_of = |name: &str| -> Option<String> {\n        let i = args.iter().position(|a| a == name)?;\n        args.get(i + 1).cloned()\n    };\n\n    if scan_mode {\n        let targets: Vec<&String> = args.iter().filter(|a| !a.starts_with(\"--\")).collect();\n        if targets.is_empty() {\n            io.err(\"embed-prompt: --scan needs at least one directory\\n\");\n            return 1;\n        }\n        let mut rasters: Vec<String> = Vec::new();\n        for t in &targets {\n            if !exists(&abs(t)) {\n                io.err(&format!(\"embed-prompt: no such path {}\\n\", t));\n                return 1;\n            }\n            // JS walks with the path as given (relative to cwd); output uses that spelling.\n            let saved = std::env::current_dir().ok();\n            let _ = std::env::set_current_dir(&cwd);\n            let r = walk(t, true, &mut rasters);\n            if let Some(s) = saved {\n                let _ = std::env::set_current_dir(s);\n            }\n            if let Err(e) = r {\n                io.err(&format!(\"Error: {}\\n\", e));\n                return 1;","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/embed_prompt.rs#L182-L218","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass at least one directory after the flags: `embed-prompt --scan <dir> [more-dirs...]`.","Quote and verify the path variable is non-empty before invoking (`echo \"$DIR\"`).","Ensure the argument does not start with `--`, or it will be filtered out as a flag.","Confirm each given path exists — a subsequent 'no such path' error means the argument was consumed but invalid."],"exampleFix":"# before\nDIR=; embed-prompt --scan $DIR\nembed-prompt: --scan needs at least one directory\n# after\nembed-prompt --scan ./src/components","handlingStrategy":"validation","validationCode":"const targets = args.filter(a => !a.startsWith('--'));\nif (scanMode && targets.length === 0) {\n  throw new Error('embed-prompt --scan requires at least one directory');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass at least one directory argument with --scan.","Verify directory variables are set and non-empty before invoking.","Ensure positional paths do not start with `--`.","Pre-check each directory exists with fs.existsSync to avoid the follow-up 'no such path' error."],"tags":["cli","missing-argument","scan","usage"],"backgroundTag":"missing-cli-argument","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}