{"record":{"id":"e20f798e10bc0d22","repo":"quarkusio/quarkus","slug":"failed-to-create-output-directory-for-generated-so","errorCode":null,"errorMessage":"Failed to create output directory for generated sources: %s","messagePattern":"Failed to create output directory for generated sources: (.+?)","errorType":"exception","errorClass":"CodeGenException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/CodeGenerator.java","lineNumber":412,"sourceCode":"                // Always return null to let MultiRootPathTree.apply() look into all roots.\n                return null;\n            });\n            return unavailableServices;\n        } catch (IOException e) {\n            throw new CodeGenException(\"Failed to read \" + dep.getResolvedPaths(), e);\n        }\n    }\n\n    private static Path codeGenOutDir(Path generatedSourcesDir,\n            CodeGenProvider provider,\n            Consumer<Path> sourceRegistrar) throws CodeGenException {\n        Path outputDir = generatedSourcesDir.resolve(provider.providerId());\n        try {\n            Files.createDirectories(outputDir);\n            sourceRegistrar.accept(outputDir);\n            return outputDir;\n        } catch (IOException e) {\n            throw new CodeGenException(\n                    \"Failed to create output directory for generated sources: \" + outputDir.toAbsolutePath(), e);\n        }\n    }\n\n    @FunctionalInterface\n    private interface CodeGenAction<T> {\n        T fire() throws CodeGenException;\n    }\n}\n","sourceCodeStart":394,"sourceCodeEnd":422,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/CodeGenerator.java#L394-L422","documentation":"CodeGenException thrown by codeGenOutDir when Files.createDirectories(outputDir) fails while preparing the output directory for a code generator provider's generated sources (target/generated-sources/src/<providerId>). The IOException (usually permissions or an existing non-directory file at that path) is wrapped in a descriptive CodeGenException. Build aborts before code generation runs.","triggerScenarios":"During code generation setup, outputDir = generatedSourcesDir.resolve(provider.providerId()) cannot be created because a parent path is a file, the disk is full, or the process lacks write permission on target/generated-sources.","commonSituations":"Read-only project directory (checkout mounted read-only, CI running with wrong user); target/generated-sources path exists as a regular file (rarely, from a broken previous build); disk quota exceeded; Windows path/permission problems.","solutions":["Delete the offending path shown in the message (or the whole target dir) so the directory can be created, then rebuild","Verify write permissions on the project directory and that the build user owns target/","Free disk space / resolve quota limits on the build volume","Run as a user with sufficient filesystem rights in CI containers"],"exampleFix":"# before: a file exists where the directory should be\ntarget/generated-sources/src/hibernate-orm  # plain file\n# after\nrm -rf target/generated-sources && mvn quarkus:build","handlingStrategy":"validation","validationCode":"Path out = generatedSourcesDir.resolve(provider.providerId());\nif (out.toFile().exists() && !out.toFile().isDirectory()) {\n    throw new IllegalStateException(\"Not a directory: \" + out + \" — delete it and rebuild\");\n}\nif (!Files.isWritable(generatedSourcesDir)) {\n    throw new IllegalStateException(\"No write permission on \" + generatedSourcesDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Files.createDirectories(outputDir);\n} catch (IOException e) {\n    throw new IllegalStateException(\"Check permissions/disk for \" + outputDir + \": \" + e.getMessage(), e);\n}","preventionTips":["Ensure the build user has write access to the project and target/ directories","Never commit or freeze target/generated-sources as files in VCS","Monitor free disk space in CI","Avoid read-only mounts for source builds"],"tags":["quarkus","io","filesystem","code-generation"],"backgroundTag":"cannot-create-directory","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}