{"record":{"id":"fe8051b82d4b2581","repo":"pbakaus/impeccable","slug":"error-cannot-scan-target-message","errorCode":null,"errorMessage":"Error: cannot scan {target}: {message}\n","messagePattern":"Error: cannot scan (.+?): (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/detect/src/cli.rs","lineNumber":250,"sourceCode":"    cwd: String,\n    home: String,\n    config: DetectionConfig,\n    json_mode: bool,\n    quiet_mode: bool,\n    design_system_enabled: bool,\n    base: ScanOptions,\n    cache: DesignSystemCache,\n    stdin_tty: bool,\n    /// JS `hadOperationalFailure`: at least one requested target could not be\n    /// scanned, which forces exit 1 (#711).\n    had_operational_failure: bool,\n}\n\nimpl<'a> Ctx<'a> {\n    /// JS: main.mjs#reportLocalScanFailure\n    fn report_local_scan_failure(&mut self, target: &str, message: &str) {\n        self.had_operational_failure = true;\n        self.io.err(&format!(\"Error: cannot scan {target}: {message}\\n\"));\n    }\n\n    fn scan_options_for(&mut self, local_path: Option<&str>) -> ScanOptions {\n        let (Some(local_path), true) = (local_path, self.design_system_enabled) else {\n            return self.base.clone();\n        };\n        match load_design_system_for_target(\n            local_path,\n            Some(&mut self.cache),\n            &self.cwd,\n            &self.home,\n        ) {\n            Some(ds) => ScanOptions {\n                design_system: Some(ds),\n                ..self.base.clone()\n            },\n            None => self.base.clone(),\n        }","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/detect/src/cli.rs#L232-L268","documentation":"`Ctx::report_local_scan_failure` marks the run as having an operational failure and prints `Error: cannot scan <target>: <message>` to stderr. It is the Rust port of main.mjs#reportLocalScanFailure and centralizes reporting for local-path scan targets that could not be scanned (unreadable files, bad paths, IO errors). The exit code / result handling treats `had_operational_failure = true` as a failed run even if other targets succeeded.","triggerScenarios":"Calling `impeccable detect <path>` where the local target cannot be scanned: the path does not exist, lacks read permission, is an unreadable special file, or the scanner returns an error message for that target. Any per-target scan error for a local path routes here.","commonSituations":"Typos in the file/directory path; running from the wrong working directory so a relative path resolves elsewhere; CI checkouts missing the file; permission-restricted files (e.g. created by another user); passing a directory where only files are accepted or vice versa.","solutions":["Verify the target path exists: `ls -la <target>`, and re-run with the correct relative or absolute path.","Fix file permissions (`chmod u+r <file>` / `chown`) or run from a directory where the path is readable.","If the message body indicates an internal scan error, reproduce with a minimal file and report it; meanwhile exclude the broken target from the target list."],"exampleFix":"// before\nimpeccable detect src/page.htm   // typo: file not found\n// after\nimpeccable detect src/page.html","handlingStrategy":"validation","validationCode":"import fs from \"node:fs\";\nfor (const t of targets) {\n  if (!fs.existsSync(t) || !fs.accessSync(t, fs.constants.R_OK)) {\n    throw new Error(`target not readable: ${t}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"const r = spawnSync(\"impeccable\", [\"detect\", target]);\nif (r.status !== 0 && r.stderr.toString().startsWith(\"Error: cannot scan\")) {\n  console.error(`Skipping unreadable target ${target}; check path/permissions.`);\n}","preventionTips":["Resolve relative paths against a known cwd before invoking","Pre-check existence and read permission of every target","In CI, verify checkout contents before running scans"],"tags":["cli","scan","file-system","operational-failure"],"backgroundTag":"file-not-found","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}