{"record":{"id":"2e8473cad2f20f2e","repo":"sebastianbergmann/phpunit","slug":"the-path-s-specified-for-the-log-events-text","errorCode":null,"errorMessage":"The path \"%s\" specified for the --log-events-text option could not be resolved","messagePattern":"The path \"(.+?)\" specified for the --log-events-text option could not be resolved","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/TextUI/Configuration/Cli/Builder.php","lineNumber":1392,"sourceCode":"\n                    break;\n\n                case '--ignore-dependencies':\n                    $resolveDependencies = false;\n\n                    break;\n\n                case '--reverse-order':\n                    $executionOrder = TestSuiteSorter::ORDER_REVERSED;\n\n                    break;\n\n                case '--log-events-text':\n                    $logEventsTextPath = $this->requireNonEmptyValue($option[1], '--log-events-text');\n                    $logEventsText     = Filesystem::resolveStreamOrFile($logEventsTextPath);\n\n                    if ($logEventsText === false) {\n                        throw new Exception(\n                            sprintf(\n                                'The path \"%s\" specified for the --log-events-text option could not be resolved',\n                                $logEventsTextPath,\n                            ),\n                        );\n                    }\n\n                    break;\n\n                case '--log-events-verbose-text':\n                    $logEventsVerboseTextPath = $this->requireNonEmptyValue($option[1], '--log-events-verbose-text');\n                    $logEventsVerboseText     = Filesystem::resolveStreamOrFile($logEventsVerboseTextPath);\n\n                    if ($logEventsVerboseText === false) {\n                        throw new Exception(\n                            sprintf(\n                                'The path \"%s\" specified for the --log-events-verbose-text option could not be resolved',\n                                $logEventsVerboseTextPath,","sourceCodeStart":1374,"sourceCodeEnd":1410,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/TextUI/Configuration/Cli/Builder.php#L1374-L1410","documentation":"PHPUnit throws this while building the CLI configuration when the value of --log-events-text is neither a php:// or socket:// stream nor a path whose parent directory exists. Filesystem::resolveStreamOrFile() (src/Util/Filesystem.php:37) returns false exactly when dirname($path) is not an existing directory, and the Builder converts that into this exception. PHPUnit refuses to start because it cannot determine where the test-runner event log should be written; it does not create missing parent directories for this option.","triggerScenarios":"Running `vendor/bin/phpunit --log-events-text=build/events.txt` when `build/` does not exist; a relative or bare path whose parent directory was deleted or never created; a path like `/tmp/missing-dir/events.log` with an absent intermediate directory. Values prefixed with php:// or socket://, or paths whose dirname exists (the file itself may not exist yet), resolve fine.","commonSituations":"CI jobs writing event logs into directories that are not committed to the repo and never mkdir'd; scripts moved to a different working directory so a relative path no longer resolves; users assuming PHPUnit creates output directories like some coverage report targets do.","solutions":["Create the parent directory before running: `mkdir -p build && vendor/bin/phpunit --log-events-text=build/events.txt`","Use a path whose parent directory already exists, ideally an absolute path","Use a stream wrapper such as `--log-events-text=php://stderr` or `php://stdout` when you do not need a file","When invoking the runner from PHP, pre-check `is_dir(dirname($path))` and create the directory (or drop the option) before building the configuration"],"exampleFix":"# before\nvendor/bin/phpunit --log-events-text=build/events.txt   # build/ does not exist\n\n# after\nmkdir -p build\nvendor/bin/phpunit --log-events-text=build/events.txt\n\n# alternative (no file needed)\nvendor/bin/phpunit --log-events-text=php://stderr","handlingStrategy":"validation","validationCode":"use function str_starts_with;\n\nfunction eventLogTargetResolves(string $path): bool\n{\n    if (str_starts_with($path, 'php://') || str_starts_with($path, 'socket://')) {\n        return true;\n    }\n\n    return is_dir(dirname($path));\n}\n\n// before shelling out / building CLI configuration:\n$path = 'build/events.txt';\n\nif (!eventLogTargetResolves($path)) {\n    mkdir(dirname($path), 0777, true);\n}\n\n// safe: --log-events-text=$path","typeGuard":null,"tryCatchPattern":"try {\n    $cliConfig = (new \\PHPUnit\\TextUI\\CliArguments\\Builder)->fromParameters($_SERVER['argv']);\n} catch (\\PHPUnit\\TextUI\\CliArguments\\Exception $e) {\n    // configuration-time failures, including unresolvable --log-events-text paths\n    fwrite(STDERR, 'phpunit configuration error: ' . $e->getMessage() . PHP_EOL);\n    exit(1);\n}","preventionTips":["In CI, create output directories in a setup step: mkdir -p before running phpunit","Prefer php://stderr or php://stdout for ad-hoc event logging so no filesystem is involved","When wrapping PHPUnit in scripts, validate every file-output option with is_dir(dirname($path)) before exec"],"tags":["phpunit","cli","logging","event-log","filesystem","path-resolution"],"backgroundTag":"unresolvable-output-path","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}