{"record":{"id":"525c862de624482c","repo":"sebastianbergmann/phpunit","slug":"error-in-bootstrap-script-s-s-s-s-s","errorCode":null,"errorMessage":"Error in bootstrap script: %s:%s%s%s%s","messagePattern":"Error in bootstrap script: (.+?):(.+?)(.+?)(.+?)(.+?)","errorType":"exception","errorClass":"BootstrapScriptException","httpStatus":null,"severity":"error","filePath":"src/TextUI/Configuration/BootstrapLoader.php","lineNumber":85,"sourceCode":"                $t->getMessage(),\n                PHP_EOL,\n                $t->getTraceAsString(),\n            );\n\n            while (($t = $t->getPrevious()) !== null) {\n                $message .= sprintf(\n                    '%s%sPrevious error: %s:%s%s%s%s',\n                    PHP_EOL,\n                    PHP_EOL,\n                    $t::class,\n                    PHP_EOL,\n                    $t->getMessage(),\n                    PHP_EOL,\n                    $t->getTraceAsString(),\n                );\n            }\n\n            throw new BootstrapScriptException($message);\n        }\n\n        EventFacade::emitter()->testRunnerBootstrapFinished($filename);\n    }\n}\n","sourceCodeStart":67,"sourceCodeEnd":91,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/TextUI/Configuration/BootstrapLoader.php#L67-L91","documentation":"After the readability check, BootstrapLoader::load() includes the bootstrap script inside a try/catch (Throwable). Any exception or error escaping the include — a thrown exception, a PHP 8 ParseError from a syntax error, a TypeError during setup — is rethrown as BootstrapScriptException('Error in bootstrap script: %s:%s%s%s%s') containing the exception class, its message, its stack trace, and one 'Previous error:' block per chained previous exception. The run aborts before any test executes.","triggerScenarios":"A syntax error in the bootstrap file; an exception thrown while the bootstrap registers autoloaders, constants, or environment setup; a missing dependency the bootstrap tries to use (e.g. referencing a vendor package that is not installed).","commonSituations":"Editing bootstrap.php and introducing a parse error; bootstrap code depending on env vars or files missing in CI; composer dependency updates that break bootstrap assumptions; PHP version mismatch making the bootstrap file unparsable.","solutions":["Read the embedded exception class, message and trace — they name the real failure inside the bootstrap script; fix that root cause.","Lint the bootstrap to catch syntax errors quickly: php -l bootstrap.php.","Ensure everything the bootstrap needs (env vars, vendor dependencies, files) is present in the environment phpunit runs in."],"exampleFix":"// before (bootstrap.php)\nrequire __DIR__ . '/helpers/Env.php'; // throws: helpers/Env.php missing\n\n// after (bootstrap.php)\nif (!is_file(__DIR__ . '/helpers/Env.php')) {\n    throw new RuntimeException('Run \"composer install\" before testing');\n}\nrequire __DIR__ . '/helpers/Env.php';","handlingStrategy":"try-catch","validationCode":"# catch syntax errors before running the suite\nphp -l bootstrap.php","typeGuard":null,"tryCatchPattern":"// when invoking the loader programmatically\nuse \\PHPUnit\\TextUI\\Configuration\\BootstrapScriptException;\n\ntry {\n    $bootstrapLoader->handle($configuration);\n} catch (BootstrapScriptException $e) {\n    // message embeds the original exception class, message, trace and\n    // 'Previous error' chains — surface it verbatim in CI logs and stop\n    fwrite(STDERR, $e->getMessage() . PHP_EOL);\n    exit(1);\n}","preventionTips":["Run php -l on the bootstrap in CI as a cheap parse check.","Keep bootstrap scripts small: only autoloading and constant/env setup; move real logic into testable classes.","Fail with clear messages from the bootstrap itself when required env vars or files are missing, so PHPUnit surfaces your text instead of a low-level error."],"tags":["phpunit","bootstrap","syntax-error","configuration","startup-failure"],"backgroundTag":"bootstrap-script-failed","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}