{"record":{"id":"e6ee619cc83104e8","repo":"pbakaus/impeccable","slug":"comp-spec-cannot-read-comp-path-e","errorCode":null,"errorMessage":"comp-spec: cannot read {comp_path}: {e}\n","messagePattern":"comp-spec: cannot read (.+?): (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/comp-verbs/src/comp_spec.rs","lineNumber":878,"sourceCode":"            }\n            Err(e) => {\n                io.err(&format!(\"comp-spec: {e}\\n\"));\n                return 1;\n            }\n        }\n        io.out(&format!(\"CROP {out} ({}x{}) region {id} of {comp_file}. Reference only: regenerate the plate from it, never ship it.\\n\", c.width, c.height));\n        return 0;\n    }\n\n    let comp_path = arg(argv, \"comp\");\n    let Some(comp_path) = comp_path else {\n        io.err(\"usage: comp-spec.mjs --comp <png> (--grid | --regions <json> | --auto) [--spec out.json]\\n       comp-spec.mjs --print | --crop <id> [--out file] [--scale n] | --plate-prompt <id>\\n\");\n        return 1;\n    };\n    let comp = match png_io::load_raster(&resolve(io, comp_path)) {\n        Ok((d, _)) => d.image,\n        Err(e) => {\n            io.err(&format!(\"comp-spec: cannot read {comp_path}: {e}\\n\"));\n            return 1;\n        }\n    };\n\n    if flag(argv, \"grid\") {\n        let grid_out = resolve(io, GRID_PATH);\n        if let Some(parent) = grid_out.parent() {\n            let _ = std::fs::create_dir_all(parent);\n        }\n        match png_io::encode_png(&render_grid(&comp), &[]) {\n            Ok(bytes) => {\n                let _ = std::fs::write(&grid_out, bytes);\n            }\n            Err(e) => {\n                io.err(&format!(\"comp-spec: {e}\\n\"));\n                return 1;\n            }\n        }","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/comp-verbs/src/comp_spec.rs#L860-L896","documentation":"Once --comp is provided, comp-spec loads the composition image via png_io::load_raster. This error is thrown when the image at the --comp path cannot be read or decoded as a raster, preventing grid rendering or region measurement.","triggerScenarios":"--comp points to a nonexistent file, a directory, a file without read permission, or a non-PNG/undecodable file (e.g. a JPEG, SVG, or truncated PNG). Relative paths are resolved against the current working directory, so running from elsewhere also triggers this.","commonSituations":"Typos in the image path; passing a JPG or SVG exported from a design tool; the screenshot/export step failed silently leaving a zero-byte file; CI running from a different working directory.","solutions":["Verify the path exists and is readable (`ls -l <path>`), and run from the intended directory or pass an absolute path.","Convert the image to PNG first (e.g. `magick input.jpg comp.png`) if it is another raster format.","Re-export/re-capture the composition if the file is truncated or zero bytes.","SVG inputs must be rasterized to PNG before use."],"exampleFix":"// before\ncomp-spec --comp comp.jpg --grid\n// after\nmagick comp.jpg comp.png\ncomp-spec --comp comp.png --grid","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'fs';\nconst buf = readFileSync(compPath);           // throws if missing/unreadable\nif (!(buf.length > 8 && buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47)) {\n  throw new Error(`${compPath} is not a PNG; convert it first`);\n}","typeGuard":"function isPngFile(p) {\n  const b = fs.readFileSync(p);\n  return b.length > 8 && b[0] === 0x89 && b[1] === 0x50 && b[2] === 0x4e && b[3] === 0x47;\n}","tryCatchPattern":null,"preventionTips":["Convert JPG/SVG/WEBP sources to PNG before passing --comp.","Use absolute paths or run comp-spec from a fixed working directory.","Verify the export/screenshot step produced a non-empty PNG before measuring.","Check file permissions in CI environments."],"tags":["cli","file-read","png"],"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"}