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
- Check the parent path: delete or rename any file that occupies the target directory path
- Run the build/dev-mode with a user that has write permissions to the project and target directories
- Free disk space or raise quota if the disk is full
- 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
- Verify the dev-mode working directories are writable before starting quarkus:dev (especially in CI containers)
- Never place a regular file where a directory is expected (e.g. a file named 'classes')
- Monitor disk space/quota on build machines
- Run builds as a dedicated user with ownership of the workspace
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
- Failed to create output directory for generated sources: %s
- IOException (wrapped)
- Unable to validate the application root for remote-dev path:
- Unable to validate remote-dev path: <file>
- Cannot initialize file manager
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a9b874436edcf456.
Report an issue: GitHub.