{"record":{"id":"043fd76008dc6ae0","repo":"quarkusio/quarkus","slug":"failed-to-create-the-output-dir-projectfile","errorCode":null,"errorMessage":"Failed to create the output dir ${projectFile}","messagePattern":"Failed to create the output dir (.+?)","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java","lineNumber":519,"sourceCode":"\n        private ResolvedDependencyBuilder getApplicationArtifactBuilder(QuarkusBootstrapMojo mojo)\n                throws MojoExecutionException {\n            String appArtifactCoords = mojo.appArtifactCoords();\n            if (appArtifactCoords == null) {\n                final Artifact projectArtifact = mojo.mavenProject().getArtifact();\n\n                File projectFile = projectArtifact.getFile();\n                if (projectFile == null) {\n                    projectFile = new File(mojo.mavenProject().getBuild().getOutputDirectory());\n                    if (!projectFile.exists()) {\n                        /*\n                         * TODO GenerateCodeMojo would fail\n                         * if (hasSources(project)) {\n                         * throw new MojoExecutionException(\"Project \" + project.getArtifact() + \" has not been compiled yet\");\n                         * }\n                         */\n                        if (!projectFile.mkdirs()) {\n                            throw new MojoExecutionException(\"Failed to create the output dir \" + projectFile);\n                        }\n                    }\n                }\n                return ResolvedDependencyBuilder.newInstance()\n                        .setGroupId(projectArtifact.getGroupId())\n                        .setArtifactId(projectArtifact.getArtifactId())\n                        .setClassifier(projectArtifact.getClassifier())\n                        .setType(projectArtifact.getArtifactHandler().getExtension())\n                        .setVersion(projectArtifact.getVersion())\n                        .setResolvedPath(projectFile.toPath());\n            }\n\n            final String[] coordsArr = appArtifactCoords.split(\":\");\n            if (coordsArr.length < 2 || coordsArr.length > 5) {\n                throw new MojoExecutionException(\n                        \"appArtifact expression \" + appArtifactCoords\n                                + \" does not follow format groupId:artifactId:classifier:type:version\");\n            }","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java#L501-L537","documentation":"QuarkusBootstrapProvider.getApplicationArtifactBuilder represents the current Maven project as a resolved application artifact for the Quarkus bootstrap. When the project artifact file does not exist yet (project not compiled), it falls back to the configured output directory and attempts mkdirs(); if directory creation fails (permissions, path is a file, disk issues) it throws this MojoExecutionException naming the directory.","triggerScenarios":" mojo.appArtifactCoords() is null, projectArtifact.getFile() returns null (project not yet packaged/compiled), the target output directory does not exist, and File.mkdirs() returns false because the directory could not be created.","commonSituations":"Running quarkus mojos on a clean project without a prior compile; read-only workspace or CI checkout with restrictive permissions; a file already exists at the target/classes path; running from a sandboxed environment denying writes to the module directory; disk-full conditions.","solutions":["Run mvn compile (or mvn package) before the Quarkus mojo so the project artifact file exists","Check filesystem permissions on the module's target/ directory and ensure the build user can write","Verify the path named in the error is not an existing regular file blocking directory creation","Check available disk space and any sandbox/readonly-mount restrictions","Set appArtifactCoords explicitly to a resolvable artifact if the project artifact is intentionally absent"],"exampleFix":"// CI pipeline\n// before — Quarkus mojo runs before compilation\nmvn quarkus:build\n// after — compile first so the artifact file exists\nmvn compile quarkus:build","handlingStrategy":"validation","validationCode":"// Before invoking the Quarkus mojo, verify the output directory is creatable\nFile outDir = new File(project.getBuild().getOutputDirectory());\nif (!outDir.exists() && !outDir.getParentFile().canWrite()) {\n    throw new IllegalStateException(\"Cannot write to build output directory: \" + outDir.getParentFile());\n}\nif (outDir.exists() && !outDir.isDirectory()) {\n    throw new IllegalStateException(\"Build output path exists and is not a directory: \" + outDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    quarkusMojo.execute();\n} catch (MojoExecutionException e) {\n    if (e.getMessage().startsWith(\"Failed to create the output dir\")) {\n        File dir = new File(e.getMessage().substring(e.getMessage().lastIndexOf(' ') + 1));\n        getLog().error(\"Cannot create \" + dir + \": check permissions, that the path is not a file, and disk space.\");\n    } else { throw e; }\n}","preventionTips":["Always compile (mvn compile) before running Quarkus mojos so the project artifact exists","Ensure CI workspaces grant write access to the module target/ directory","Verify the output path is not occupied by a regular file","Monitor disk space in build environments","Consider setting appArtifactCoords explicitly when the project artifact is intentionally absent"],"tags":["maven","filesystem","build","io"],"backgroundTag":"output-directory-creation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}