{"record":{"id":"3fd85b0238fecdaf","repo":"quarkusio/quarkus","slug":"failed-to-create-the-project-directory-targetdi","errorCode":null,"errorMessage":"Failed to create the project directory: + targetDirectory","messagePattern":"Failed to create the project directory: \\+ targetDirectory","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartProcessor.java","lineNumber":66,"sourceCode":"    }\n\n    void process(final CodestartResource projectResource, final Codestart codestart) {\n        log.debug(\"processing codestart '%s'...\", codestart.getName());\n        addBuiltinData();\n        codestart.use(l -> {\n            final Map<String, Object> finalData = CodestartData.buildCodestartData(codestart, languageName, data);\n            log.debug(\"codestart data: %s\", finalData);\n            Stream.of(BASE_LANGUAGE, languageName)\n                    .filter(l::dirExists)\n                    .forEach(languageDir -> processLanguageDir(projectResource, l, languageDir, finalData));\n        });\n    }\n\n    public void checkTargetDir() throws IOException {\n        if (!Files.exists(targetDirectory)) {\n            boolean mkdirStatus = targetDirectory.toFile().mkdirs();\n            if (!mkdirStatus) {\n                throw new IOException(\"Failed to create the project directory: \" + targetDirectory);\n            }\n            return;\n        }\n        if (!Files.isDirectory(targetDirectory)) {\n            throw new IOException(\"Project path needs to point to a directory: \" + targetDirectory);\n        }\n        final String[] files = targetDirectory.toFile().list();\n        if (files != null && files.length > 0) {\n            throw new IOException(\"You can't create a project when the directory is not empty: \" + targetDirectory);\n        }\n    }\n\n    public void writeFiles() throws IOException {\n        for (Map.Entry<String, List<TargetFile>> e : files.entrySet()) {\n            final String relativePath = e.getKey();\n            final CodestartFileStrategyHandler strategy = getStrategy(relativePath).orElse(getSelectedDefaultStrategy());\n            log.debug(\"processing file '%s' with strategy %s\", relativePath, strategy.name());\n            strategy.process(targetDirectory, relativePath, e.getValue(), data);","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartProcessor.java#L48-L84","documentation":"CodestartProcessor.checkTargetDir() throws IOException('Failed to create the project directory: <targetDirectory>') when the target directory does not exist and File.mkdirs() returns false — i.e. the directory (including parents) could not be created, usually due to permissions or an invalid path.","triggerScenarios":"Project generation into a path where mkdirs() fails: no write permission on the parent, path is on a read-only filesystem, or the path is invalid/already exists as a file created concurrently.","commonSituations":"Generating a project into a protected system location; running the CLI as a user without rights on the target parent; typoed or overly long paths on Windows.","solutions":["Check and fix write permissions on the parent directory (e.g. chown/chmod or choose another location).","Verify the target path is valid and its parent exists / is writable.","Create the directory manually beforehand if the generator runs in a restricted environment."],"exampleFix":"// before\nmkdirs fails on /root/projects (no permission)\n// after\ncode.quarkus.io target: /home/user/projects/my-app  (writable location)","handlingStrategy":"validation","validationCode":"Path target = Path.of(dest);\nPath parent = target.toAbsolutePath().getParent();\nif (parent == null || !Files.isWritable(parent)) {\n    throw new IllegalArgumentException(\"Cannot create project: parent not writable: \" + parent);\n}","typeGuard":null,"tryCatchPattern":"try {\n    processor.generateProject(...);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Failed to create the project directory\")) {\n        logger.error(\"Check permissions/validity of: \" + targetDir);\n    }\n    throw e;\n}","preventionTips":["Verify write permissions on the destination parent before generating.","Avoid system/protected directories as generation targets.","Pre-create the target directory with correct ownership in CI/containers."],"tags":["filesystem","permissions","io","project-generation"],"backgroundTag":"mkdir-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"}