quarkusio/quarkus · error · RuntimeException

Cannot create directory ${directory}

Error message

Cannot create directory ${directory}

What it means

Thrown by QuarkusFileManager.ensureDirectory when File.mkdirs() fails to create a required directory on disk during live-reload/dev-mode file manager setup. This is a filesystem-level failure: the process could not create the directory, usually because of permissions, an existing non-directory file at that path, or a full/failed disk.

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/dev/filesystem/QuarkusFileManager.java:66

                // Paths might be missing! (see: https://github.com/quarkusio/quarkus/issues/42908)
                ensureDirectories(context.getAnnotationProcessorPaths());
                this.fileManager.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, context.getAnnotationProcessorPaths());
            }
        } catch (IOException e) {
            throw new RuntimeException("Cannot reset file manager", e);
        }
    }

    private void ensureDirectories(Iterable<File> directories) {
        for (File directory : directories) {
            ensureDirectory(directory);
        }
    }

    private void ensureDirectory(File directory) {
        if (!directory.exists()) {
            if (!directory.mkdirs()) {
                throw new RuntimeException("Cannot create directory " + directory);
            }
        }
    }

    @Override
    public void close() throws IOException {
        super.close();
    }

    public static class Context {
        private final Set<File> classPath;
        private final Set<File> reloadableClassPath;
        private final File outputDirectory;
        private final Charset sourceEncoding;
        private final boolean ignoreModuleInfo;
        private final File generatedSourcesDirectory;
        private final Set<File> annotationProcessorPaths;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check the parent path: delete or rename any file that occupies the target directory path
  2. Run the build/dev-mode with a user that has write permissions to the project and target directories
  3. Free disk space or raise quota if the disk is full
  4. Set a writable quarkus dev-mode working directory / run from a writable checkout

Example fix

// before: running dev mode in a read-only container
FROM ... USER nobody
// after: mount workspace writable or run as a user with write access
USER quarkus
RUN mkdir -p /workspace && chown quarkus /workspace
Defensive patterns

Strategy: validation

Validate before calling

File dir = new File(path);
if (!dir.exists() && (dir.getParentFile() == null || !dir.getParentFile().canWrite() || (dir.exists() && !dir.isDirectory()))) {
    throw new IllegalStateException("Cannot create directory " + dir + ": parent not writable or path occupied by a file");
}

Type guard

static boolean canCreateDir(File d) {
    if (d.isDirectory()) return true;
    File parent = d.getAbsoluteFile().getParentFile();
    return parent != null && parent.canWrite();
}

Try / catch

try {
    ensureDirectories();
} catch (RuntimeException e) {
    if (e.getMessage().startsWith("Cannot create directory")) {
        // check permissions/disk for the path in the message
    }
    throw e;
}

Prevention

When it happens

Trigger: Java calling ensureDirectories/reset on QuarkusFileManager while dev-mode working directories (e.g. under target/) cannot be created because mkdirs() returns false.

Common situations: Read-only workspace or CI volume; a file named like the expected directory exists at the path; disk quota exceeded; running dev mode as a user without write access to the project root; NFS/Windows path conflicts.

Related errors


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