{"record":{"id":"29cd7a290637132d","repo":"elastic/elasticsearch","slug":"could-not-create-output-directory-parent","errorCode":null,"errorMessage":"Could not create output directory: {parent}","messagePattern":"Could not create output directory: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/foreign/AugmentForeignModuleInfoTask.java","lineNumber":68,"sourceCode":"    @InputFile\n    @PathSensitive(PathSensitivity.NAME_ONLY)\n    public abstract RegularFileProperty getServicesFile();\n\n    @Classpath\n    public abstract ConfigurableFileCollection getAugmenterClasspath();\n\n    @Nested\n    public abstract Property<JavaLauncher> getJavaLauncher();\n\n    @OutputFile\n    public abstract RegularFileProperty getOutputModuleInfo();\n\n    @TaskAction\n    public void augment() {\n        File outputFile = getOutputModuleInfo().get().getAsFile();\n        File parent = outputFile.getParentFile();\n        if (parent != null && parent.mkdirs() == false && parent.isDirectory() == false) {\n            throw new IllegalStateException(\"Could not create output directory: \" + parent);\n        }\n\n        String javaExecutable = getJavaLauncher().get().getExecutablePath().getAsFile().getAbsolutePath();\n\n        execOperations.exec(spec -> {\n            spec.executable(javaExecutable);\n            spec.args(\"-cp\", getAugmenterClasspath().getAsPath());\n            spec.args(\"org.elasticsearch.foreign.processor.ModuleInfoAugmenter\");\n            spec.args(\n                getInputModuleInfo().get().getAsFile().getAbsolutePath(),\n                getServicesFile().get().getAsFile().getAbsolutePath(),\n                outputFile.getAbsolutePath()\n            );\n        }).assertNormalExitValue();\n    }\n}\n","sourceCodeStart":50,"sourceCodeEnd":85,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/foreign/AugmentForeignModuleInfoTask.java#L50-L85","documentation":"Thrown by AugmentForeignModuleInfoTask.augment() when the parent directory of the configured output module-info file cannot be created. The task runs ModuleInfoAugmenter as an external Java process to process module-info.java files. Before launching the process, it ensures the output directory exists via mkdirs(). The guard checks parent != null, mkdirs() == false, and isDirectory() == false.","triggerScenarios":"The output file's parent directory does not exist, mkdirs() returns false (because of a conflicting file, permissions, or read-only filesystem), and isDirectory() returns false. The three-condition guard avoids throwing when mkdirs() returns false because the directory already existed (a benign race or pre-existing directory).","commonSituations":"The OutputModuleInfo property is configured to a path whose parent is a regular file. The build directory is read-only. The output path resolves outside the project (e.g., a typo in the configuration). A stale file occupies the path where a directory is expected.","solutions":["Run ./gradlew clean to remove any stale files conflicting with the expected directory path.","Verify the output module-info path is set to a location within the build directory.","Ensure the Gradle daemon has write permissions to the parent path.","Check for path conflicts: ls -la on the parent path to confirm no regular file occupies the directory slot."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate output path before task\nFile parent = outputFile.getParentFile();\nif (parent != null && parent.exists() && !parent.isDirectory()) {\n    throw new GradleException(\"Output parent exists as a non-directory file: \" + parent);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure the output module-info path within the build directory.","Run ./gradlew clean to clear stale file/directory conflicts.","Ensure write permissions on the build directory."],"tags":["jpms","module-info","filesystem","build-task","io"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}