{"record":{"id":"fa21932be4a8b700","repo":"quarkusio/quarkus","slug":"failed-to-create-directory-dir","errorCode":null,"errorMessage":"Failed to create directory ${dir}","messagePattern":"Failed to create directory (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/util/IoUtils.java","lineNumber":39,"sourceCode":"import java.nio.file.attribute.BasicFileAttributes;\nimport java.util.EnumSet;\nimport java.util.Objects;\nimport java.util.UUID;\n\nimport org.jboss.logging.Logger;\n\n/**\n *\n * @author Alexey Loubyansky\n */\npublic class IoUtils {\n\n    private static final Path TMP_DIR = Paths.get(PropertyUtils.getProperty(\"java.io.tmpdir\"));\n\n    private static final Logger log = Logger.getLogger(IoUtils.class);\n\n    private static void failedToMkDir(final Path dir) {\n        throw new IllegalStateException(\"Failed to create directory \" + dir);\n    }\n\n    public static Path createTmpDir(String name) {\n        return mkdirs(TMP_DIR.resolve(name));\n    }\n\n    public static Path createRandomTmpDir() {\n        return createTmpDir(UUID.randomUUID().toString());\n    }\n\n    public static Path createRandomDir(Path parentDir) {\n        return mkdirs(parentDir.resolve(UUID.randomUUID().toString()));\n    }\n\n    public static Path mkdirs(Path dir) {\n        try {\n            Files.createDirectories(dir);\n        } catch (IOException e) {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/util/IoUtils.java#L21-L57","documentation":"IoUtils.failedToMkDir throws IllegalStateException when a directory could not be created on the filesystem. The library throws it from mkdir/mkdirs helpers (e.g. IoUtils.createTmpDir) when java.nio.file.Files.createDirectories fails silently (File.mkdir/mkdirs return false). It indicates a filesystem-level problem, not a programming error in most cases.","triggerScenarios":"Calling IoUtils.createTmpDir(name) (which resolves a path under java.io.tmpdir and calls mkdirs) or IoUtils.mkdir(s)(path) when the directory already exists as a regular file, the parent is not writable, or the path exceeds the OS filename length limit.","commonSituations":"A stale file occupies the temp directory name from a previous crashed run; read-only temp disk or full disk; running in a container with an unwritable /tmp; permission changes after switching the user the process runs as.","solutions":["Check whether a plain file exists at the target path and delete it before retrying","Verify the process user has write permission on java.io.tmpdir (or the target parent directory)","Free disk space / check filesystem is not mounted read-only","Wrap the call and fall back to Files.createTempDirectory for a unique directory name"],"exampleFix":"// before\nPath dir = IoUtils.createTmpDir(\"quarkus-build\");\n// after\nPath base = Paths.get(System.getProperty(\"java.io.tmpdir\"));\nPath dir = Files.exists(base.resolve(\"quarkus-build\"))\n    ? base.resolve(\"quarkus-build\")\n    : IoUtils.createTmpDir(\"quarkus-build\");","handlingStrategy":"validation","validationCode":"Path dir = tmpDir.resolve(name);\nif (Files.exists(dir) && !Files.isDirectory(dir))\n    throw new IllegalStateException(dir + \" exists as a file; remove it first\");\nif (!Files.isWritable(dir.getParent()))\n    throw new IllegalStateException(\"No write permission on \" + dir.getParent());","typeGuard":null,"tryCatchPattern":"try {\n    Path dir = IoUtils.createTmpDir(\"quarkus-build\");\n} catch (IllegalStateException e) {\n    // fall back to a unique dir\n    Path dir2 = Files.createTempDirectory(\"quarkus-build\");\n}","preventionTips":["Check java.io.tmpdir is writable for the user running the process","Clean stale temp files from crashed runs before reusing fixed directory names","Prefer Files.createTempDirectory for unique directories","Monitor disk space in CI/container environments"],"tags":["filesystem","io","directory-creation","bootstrap"],"backgroundTag":"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"}