{"record":{"id":"dd3dfc2e19fe6789","repo":"junit-team/junit5","slug":"failed-to-create-output-directory","errorCode":null,"errorMessage":"Failed to create output directory","messagePattern":"Failed to create output directory","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/AbstractExtensionContext.java","lineNumber":197,"sourceCode":"\t\t\t() -> \"name must not contain path separators: \" + name);\n\t\ttry {\n\t\t\taction.accept(path);\n\t\t}\n\t\tcatch (Throwable t) {\n\t\t\tUnrecoverableExceptions.rethrowIfUnrecoverable(t);\n\t\t\tthrow new JUnitException(\"Failed to publish path\", t);\n\t\t}\n\t\tPreconditions.condition(Files.exists(path), () -> \"Published path must exist: \" + path);\n\t\tFileEntry fileEntry = fileEntryCreator.apply(path);\n\t\tthis.engineExecutionListener.fileEntryPublished(this.testDescriptor, fileEntry);\n\t}\n\n\tprivate Path createOutputDirectory() {\n\t\ttry {\n\t\t\treturn configuration.getOutputDirectoryCreator().createOutputDirectory(this.testDescriptor);\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new JUnitException(\"Failed to create output directory\", e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic Optional<ExtensionContext> getParent() {\n\t\treturn Optional.ofNullable(this.parent);\n\t}\n\n\t@Override\n\tpublic ExtensionContext getRoot() {\n\t\tif (this.parent != null) {\n\t\t\treturn this.parent.getRoot();\n\t\t}\n\t\treturn this;\n\t}\n\n\tprotected T getTestDescriptor() {\n\t\treturn this.testDescriptor;","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/AbstractExtensionContext.java#L179-L215","documentation":"Thrown when configuration.getOutputDirectoryCreator().createOutputDirectory(testDescriptor) raises an IOException. This creator is responsible for materializing the directory tree that per-test published files land in; if directory creation itself fails the entire publish pathway is aborted before any file write is attempted.","triggerScenarios":"createOutputDirectory() raising IOException - e.g. the configured base output path is not writable, a parent path component exists as a regular file, or the filesystem refuses to create the per-test subdirectory.","commonSituations":"Running tests with junit.platform.outputdir / junit.platform.output.dir pointed at a read-only or nonexistent location, CI without write permission to the workspace, container with an overlay fs that denies mkdir, or a custom OutputDirectoryCreator misconfigured via JupiterConfiguration.","solutions":["Point junit.platform.output.dir at a writable, existing directory (or leave unset to use a temp dir).","Grant write/execute permission to the test runner on the configured output path.","If you registered a custom OutputDirectoryCreator, ensure its createOutputDirectory never throws on the happy path and logs the underlying IOException."],"exampleFix":"// before: -Djunit.platform.output.dir=/opt/tests/out (read-only)\n// after: -Djunit.platform.output.dir=$WORKSPACE/build/test-output\nmkdir -p $WORKSPACE/build/test-output && chmod u+w $WORKSPACE/build/test-output","handlingStrategy":"validation","validationCode":"Path base = Path.of(System.getProperty(\"junit.platform.output.dir\", System.getProperty(\"java.io.tmpdir\")));\nif (!Files.exists(base) || !Files.isWritable(base)) {\n    throw new IllegalStateException(\"Output base not writable: \" + base);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set junit.platform.output.dir to an existing, writable directory in CI.","Pre-flight check the output directory writability before running tests in containers.","Avoid pointing the output dir at /opt, /etc, or other system paths."],"tags":["io","output-directory","filesystem","configuration"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}