{"record":{"id":"150570d5944ded20","repo":"quarkusio/quarkus","slug":"could-not-create-directory-dir","errorCode":null,"errorMessage":"Could not create directory ${dir}","messagePattern":"Could not create directory (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProjectHelper.java","lineNumber":162,"sourceCode":"    public static Path checkProjectRootPath(Path outputPath, String name) {\n        requireNonNull(name, \"Must specify project name\");\n        requireNonNull(outputPath, \"Must specify output path\");\n\n        Path projectRootPath = outputPath.resolve(name);\n        if (projectRootPath.toFile().exists()) {\n            throw new IllegalArgumentException(\n                    \"Target directory already exists: \" + projectRootPath.toAbsolutePath().toString());\n        }\n        return projectRootPath;\n    }\n\n    public static Path createOutputDirectory(String targetDirectory) {\n        Path origin = new File(System.getProperty(\"user.dir\")).toPath();\n        Path outputPath = (targetDirectory == null ? origin : origin.resolve(targetDirectory));\n        try {\n            Files.createDirectories(outputPath);\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\"Could not create directory \" + targetDirectory, e);\n        }\n        return outputPath;\n    }\n\n    public static Set<String> sanitizeExtensions(Set<String> extensions) {\n        if (extensions == null) {\n            return extensions = Set.of();\n        }\n        return extensions.stream().filter(Objects::nonNull).map(String::trim).collect(Collectors.toSet());\n    }\n\n    public static void addSourceTypeExtensions(Set<String> extensions, SourceType sourceType) {\n        if (sourceType == SourceType.KOTLIN) {\n            extensions.add(\"quarkus-kotlin\");\n        }\n    }\n\n    public static void handleSpringConfiguration(Map<String, Object> values) {","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProjectHelper.java#L144-L180","documentation":"createOutputDirectory wraps any IOException from Files.createDirectories into an IllegalArgumentException reporting the requested target directory. It is thrown when the directory for a generated project cannot be created (missing permissions, invalid path, or a non-directory file occupying the path).","triggerScenarios":"Calling CreateProjectHelper.createOutputDirectory with a targetDirectory that cannot be created: path segment is an existing regular file, parent dirs unwritable, or path contains illegal characters. Called during 'quarkus create' project generation.","commonSituations":"User passes a bad -o/--output-dir; running from a read-only cwd; a file named like the target dir already exists; network-mounted or Windows-reserved paths.","solutions":["Check that the target directory path does not collide with an existing file and its parent is writable","Run the create command from a writable directory or pass an explicit writable output dir","Pre-create/verify the directory manually with mkdir -p and correct permissions","Catch IllegalArgumentException and surface the underlying IOException cause for details"],"exampleFix":"// before\nPath p = CreateProjectHelper.createOutputDirectory(\"~/myapp\"); // '~' not expanded -> weird dir\n// after\nString dir = System.getProperty(\"user.home\") + \"/myapp\";\nPath p = CreateProjectHelper.createOutputDirectory(dir);","handlingStrategy":"validation","validationCode":"Path out = targetDir == null ? Path.of(System.getProperty(\"user.dir\")) : Path.of(System.getProperty(\"user.dir\")).resolve(targetDir);\nif (Files.exists(out) && !Files.isDirectory(out)) throw new IllegalStateException(\"Path exists and is not a directory: \" + out);\nPath parent = out.toAbsolutePath().getParent();\nif (parent == null || !Files.isWritable(parent)) throw new IllegalStateException(\"Parent not writable: \" + parent);","typeGuard":"static boolean isCreatableDir(Path p) {\n    return !Files.exists(p) || Files.isDirectory(p);\n}","tryCatchPattern":"try { Path p = CreateProjectHelper.createOutputDirectory(dir); } catch (IllegalArgumentException e) { log.error(\"Cannot create dir: \" + dir, e.getCause()); }","preventionTips":["Expand '~' and env vars in paths before passing them","Check for existing files with the same name as the target dir","Run generation commands from a writable directory","Prefer absolute output paths in scripts"],"tags":["filesystem","io","project-generation"],"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"}