quarkusio/quarkus · error · MojoExecutionException
Failed to create <classesDir>
Error message
Failed to create <classesDir>
What it means
ensureResolvableModule walks the dependency tree and creates target/classes directories for workspace modules whose output dirs are missing so artifacts become resolvable. If Files.createDirectories fails with an IOException, this MojoExecutionException is thrown wrapping it.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/GoOfflineMojo.java:159
if (artifact != null) {
final LocalProject module = workspace.getProject(artifact.getGroupId(), artifact.getArtifactId());
if (module != null && !module.getRawModel().getPackaging().equals(ArtifactCoords.TYPE_POM)) {
final Path classesDir;
if (artifact.getClassifier().equals(ArtifactSources.TEST)) {
classesDir = module.getTestClassesDir();
} else {
classesDir = module.getClassesDir();
}
if (!Files.exists(classesDir)) {
Path topDirToCreate = classesDir;
while (!Files.exists(topDirToCreate.getParent())) {
topDirToCreate = topDirToCreate.getParent();
}
try {
Files.createDirectories(classesDir);
createdDirs.add(topDirToCreate);
} catch (IOException e) {
throw new MojoExecutionException("Failed to create " + classesDir, e);
}
}
}
}
for (DependencyNode c : node.getChildren()) {
ensureResolvableModule(c, workspace, createdDirs);
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Check filesystem permissions on the project target/ directories and fix ownership
- Verify the path is not an existing regular file (delete it if so)
- Free disk space if the disk is full
- Run the build inside the same user context that owns the workspace
- Check container/SELinux policies if on a restricted system
Example fix
// before $ mvn quarkus:go-offline # fails creating module/target/classes // after $ sudo chown -R $(whoami) . && mvn quarkus:go-offline
Defensive patterns
Strategy: validation
Validate before calling
// pre-check target dir writability
Path target = Path.of("target");
if (Files.exists(target) && !Files.isWritable(target)) {
throw new IllegalStateException("target/ is not writable: " + target);
}
if (Files.exists(target) && !Files.isDirectory(target)) {
throw new IllegalStateException("target exists but is not a directory");
} Prevention
- Run builds as the workspace owner, not root mixing
- Ensure CI containers mount the workspace read-write
- Check disk space before large builds
- mvn clean when target state is suspect
When it happens
Trigger: Running `mvn quarkus:go-offline` when a module's target/classes path cannot be created — typically a filesystem permission problem, path is actually a file, or read-only filesystem.
Common situations: Running the build as a different user than the workspace owner; Docker container with read-only volume; SELinux/AppArmor denials; disk full on CI runners.
Related errors
- Unable to create directory: ${directory}
- Unable to collect the target directories
- Could not create directory ${outputDirectory}
- Could not create directory ${outputDirectory}
- Failed to create the output dir ${projectFile}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/fb957c4ec07981d0.
Report an issue: GitHub.