quarkusio/quarkus · error · MojoExecutionException

Failed to create ${classesDir}

Error message

Failed to create ${classesDir}

What it means

This MojoExecutionException is thrown by QuarkusProjectStateMojoBase.ensureResolvableModule when Files.createDirectories(classesDir) fails with an IOException. The mojo pre-creates target/classes directories for workspace modules so that the application model resolver can treat them as resolvable; filesystem permission problems or invalid paths cause this failure.

Source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/QuarkusProjectStateMojoBase.java:108

    private void ensureResolvableModule(DependencyNode node, LocalWorkspace workspace, List<Path> createdDirs)
            throws MojoExecutionException {
        Artifact artifact = node.getArtifact();
        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 = module.getClassesDir();
                if (!Files.exists(classesDir)) {
                    Path topDirToCreate = classesDir;
                    while (!Files.exists(topDirToCreate.getParent())) {
                        topDirToCreate = topDirToCreate.getParent();
                    }
                    try {
                        Files.createDirectories(classesDir);
                        // We keep the root target dir because it is used to store the update recipes
                        //createdDirs.add(topDirToCreate);
                    } catch (IOException e) {
                        throw new MojoExecutionException("Failed to create " + classesDir, e);
                    }
                }
            }
        }
        for (DependencyNode c : node.getChildren()) {
            ensureResolvableModule(c, workspace, createdDirs);
        }
    }

    @Override
    protected MavenArtifactResolver catalogArtifactResolver() throws MojoExecutionException {
        if (getLog().isDebugEnabled()) {
            return artifactResolver();
        } else {
            try {
                final MavenArtifactResolver baseResolver = artifactResolver();
                final DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(
                        baseResolver.getSession());

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check and fix filesystem permissions on the project's target directories (chown/chmod or run as the workspace owner)
  2. Ensure the path target/classes is a directory, not a regular file or broken symlink; remove and recreate target/
  3. Free disk space if the volume is full and re-run the goal
  4. Run the command inside the same container/user that owns the workspace

Example fix

# before
mvn quarkus:update  (fails: Failed to create /workspace/app/target/classes)
# after
sudo chown -R $(id -u):$(id -g) /workspace/app/target && mvn quarkus:update
Defensive patterns

Strategy: validation

Validate before calling

Path classesDir = Paths.get("target", "classes");
if (Files.exists(classesDir) && !Files.isDirectory(classesDir)) {
    Files.delete(classesDir); // a file occupies the path
}
if (!Files.isWritable(classesDir.getParent())) {
    throw new IllegalStateException("target/ is not writable: check permissions/disk space");
}

Try / catch

try {
    Files.createDirectories(classesDir);
} catch (IOException e) {
    // check permissions, disk space, and that no file blocks the path, then retry
}

Prevention

When it happens

Trigger: Creating target/classes under a workspace module when the target directory is read-only, owned by another user, a file occupies the path, or the derived path is invalid (e.g. special characters in module name).

Common situations: Running Maven in a container as non-root against a root-owned checkout; read-only CI workspace; disk full; target/ replaced by a symlink to an unwritable location.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/5ba3114f73ebbe7e. Report an issue: GitHub.