{"record":{"id":"4e28dc3be650ec8d","repo":"pbakaus/impeccable","slug":"comp-diff-cannot-read-comp-comp-path-e","errorCode":null,"errorMessage":"comp-diff: cannot read comp {comp_path}: {e}\n","messagePattern":"comp-diff: cannot read comp (.+?): (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/comp-verbs/src/comp_diff.rs","lineNumber":698,"sourceCode":"    } else {\n        io.cwd.join(path)\n    }\n}\n\n// ---- CLI -------------------------------------------------------------------\n\n/// `impeccable comp-diff --comp <png> --build <png> ...`\npub fn run(argv: &[String], io: &mut Io) -> i32 {\n    let comp_path = arg(argv, \"comp\");\n    let build_path = arg(argv, \"build\");\n    let (Some(comp_path), Some(build_path)) = (comp_path, build_path) else {\n        io.err(\"usage: comp-diff.mjs --comp <png> --build <png> [--spec spec.json] [--out-dir dir] [--align top|stretch] [--label name] [--threshold 0.75] [--json]\\n\");\n        return 1;\n    };\n    let comp = match read_png(io, comp_path) {\n        Ok(v) => v,\n        Err(e) => {\n            io.err(&format!(\"comp-diff: cannot read comp {comp_path}: {e}\\n\"));\n            return 1;\n        }\n    };\n    let build = match read_png(io, build_path) {\n        Ok(v) => v,\n        Err(e) => {\n            io.err(&format!(\"comp-diff: cannot read build {build_path}: {e}\\n\"));\n            return 1;\n        }\n    };\n    let mut spec: Option<Value> = None;\n    let spec_path = arg(argv, \"spec\");\n    if let Some(sp) = spec_path {\n        match std::fs::read_to_string(resolve(io, sp)) {\n            Ok(raw) => match serde_json::from_str::<Value>(&raw) {\n                Ok(v) => spec = Some(v),\n                Err(e) => {\n                    io.err(&format!(\"comp-diff: cannot read spec {sp}: {e}\\n\"));","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/comp-verbs/src/comp_diff.rs#L680-L716","documentation":"After argument validation, comp-diff reads the comp (reference) PNG via read_png. If the file cannot be read or decoded as a PNG, it reports the path plus the underlying io error and exits 1. This isolates which of the two images failed so the user is not left guessing.","triggerScenarios":"`--comp <path>` points at a nonexistent file, an unreadable path (permissions), a directory, a non-PNG file (JPEG/WebP/SVG renamed or not), or a corrupted/truncated PNG.","commonSituations":"Wrong working directory so relative paths don't resolve; the reference screenshot was never captured; the file was saved as JPEG but given a .png name; a partial download/transfer truncated the PNG.","solutions":["Verify the comp path exists: `ls -l <path>` (from the same working directory comp-diff runs in).","Confirm the file is a valid PNG (`file <path>` shows 'PNG image data').","Re-capture or re-export the reference screenshot as a real PNG.","Fix filesystem permissions if read access is denied."],"exampleFix":"// before\n$ impeccable comp-diff --comp ./missing-ref.png --build ./build.png\ncomp-diff: cannot read comp ./missing-ref.png: No such file or directory\n// after\n$ impeccable comp-diff --comp ./.impeccable/comp/ref.png --build ./build.png","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["file-io","png","image-comparison","cli"],"backgroundTag":"file-read-failed","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"}