{"record":{"id":"ba3b070de49f05ef","repo":"sebastianbergmann/phpunit","slug":"cannot-read-baseline-s-file-does-not-exist","errorCode":null,"errorMessage":"Cannot read baseline %s, file does not exist","messagePattern":"Cannot read baseline (.+?), file does not exist","errorType":"exception","errorClass":"CannotLoadBaselineException","httpStatus":null,"severity":"error","filePath":"src/Runner/Baseline/Reader.php","lineNumber":40,"sourceCode":"use PHPUnit\\Util\\Xml\\Loader as XmlLoader;\nuse PHPUnit\\Util\\Xml\\XmlException;\n\n/**\n * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit\n *\n * @internal This class is not covered by the backward compatibility promise for PHPUnit\n */\nfinal readonly class Reader\n{\n    /**\n     * @param non-empty-string $baselineFile\n     *\n     * @throws CannotLoadBaselineException\n     */\n    public function read(string $baselineFile): Baseline\n    {\n        if (!is_file($baselineFile)) {\n            throw new CannotLoadBaselineException(\n                sprintf(\n                    'Cannot read baseline %s, file does not exist',\n                    $baselineFile,\n                ),\n            );\n        }\n\n        try {\n            $document = (new XmlLoader)->loadFile($baselineFile);\n        } catch (XmlException $e) {\n            throw new CannotLoadBaselineException(\n                sprintf(\n                    'Cannot read baseline %s: %s',\n                    $baselineFile,\n                    trim($e->getMessage()),\n                ),\n            );\n        }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/Runner/Baseline/Reader.php#L22-L58","documentation":"PHPUnit was told to load a baseline (--baseline=... via configureBaseline) and Reader::read() found no regular file at that path (is_file failed). A baseline is the XML file generated by --generate-baseline that lets PHPUnit ignore known deprecations/notices/warnings; the run refuses to proceed without a readable one.","triggerScenarios":"vendor/bin/phpunit --baseline=.phpunit/baseline.xml when the file was never generated, lives at another path, or the relative path resolves against a different working directory.","commonSituations":"First run on a new checkout before generating the baseline; path typos; the baseline file not committed to the repo; CI running from a different cwd so the relative path misses.","solutions":["Check the exact path passed to --baseline (relative paths resolve from where you invoke phpunit).","Generate the file first: vendor/bin/phpunit --generate-baseline=.phpunit/baseline.xml.","If it should already exist, verify it is committed and present in the CI image."],"exampleFix":"# before\nvendor/bin/phpunit --baseline=.phpunit/baseline.xml  # file missing\n\n# after\nvendor/bin/phpunit --generate-baseline=.phpunit/baseline.xml\nvendor/bin/phpunit --baseline=.phpunit/baseline.xml","handlingStrategy":"validation","validationCode":"// Before running with --baseline\nif (!is_file($baselinePath)) {\n    fwrite(STDERR, \"Baseline {$baselinePath} missing; generating it first\\n\");\n    exit(1); // or shell_exec('vendor/bin/phpunit --generate-baseline=' . escapeshellarg($baselinePath));\n}","typeGuard":null,"tryCatchPattern":"try {\n    $baseline = (new Reader())->read($baselineFile);\n} catch (CannotLoadBaselineException $e) {\n    // regenerate and retry once, or fail with a clear message\n}","preventionTips":["Generate the baseline in the same CI step that consumes it.","Commit the baseline file if teams share it, and verify its path in CI.","Use paths relative to the project root and invoke phpunit from a fixed cwd."],"tags":["phpunit","php","baseline","configuration"],"backgroundTag":"baseline-file-not-found","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}