{"record":{"id":"faa4ccaecf2749f3","repo":"OpenAPITools/openapi-generator","slug":"could-not-generate-supporting-file-ignorefilenam","errorCode":null,"errorMessage":"Could not generate supporting file '{ignoreFileNameTarget}'","messagePattern":"Could not generate supporting file '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java","lineNumber":1153,"sourceCode":"        if (config.openapiGeneratorIgnoreList() == null || config.openapiGeneratorIgnoreList().isEmpty()) {\n            final String openapiGeneratorIgnore = \".openapi-generator-ignore\";\n            String ignoreFileNameTarget = config.outputFolder() + File.separator + openapiGeneratorIgnore;\n            File ignoreFile = new File(ignoreFileNameTarget);\n            if (generateMetadata) {\n                try {\n                    boolean shouldGenerate = !ignoreFile.exists();\n                    if (shouldGenerate && supportingFilesToGenerate != null && !supportingFilesToGenerate.isEmpty()) {\n                        shouldGenerate = supportingFilesToGenerate.contains(openapiGeneratorIgnore);\n                    }\n                    File written = processTemplateToFile(bundle, openapiGeneratorIgnore, ignoreFileNameTarget, shouldGenerate, CodegenConstants.SUPPORTING_FILES);\n                    if (written != null) {\n                        files.add(written);\n                        if (config.isEnablePostProcessFile() && !dryRun) {\n                            config.postProcessFile(written, \"openapi-generator-ignore\");\n                        }\n                    }\n                } catch (Exception e) {\n                    throw new RuntimeException(\"Could not generate supporting file '\" + ignoreFileNameTarget + \"'\", e);\n                }\n            } else {\n                this.templateProcessor.skip(ignoreFile.toPath(), \"Skipped by generateMetadata option supplied by user.\");\n            }\n        }\n\n        generateVersionMetadata(files);\n    }\n\n    Map<String, Object> buildSupportFileBundle(List<OperationsMap> allOperations, List<ModelMap> allModels, List<ModelMap> aliasModels) {\n        return this.buildSupportFileBundle(allOperations, allModels, aliasModels, null);\n    }\n\n    Map<String, Object> buildSupportFileBundle(List<OperationsMap> allOperations, List<ModelMap> allModels, List<ModelMap> aliasModels, List<WebhooksMap> allWebhooks) {\n\n        Map<String, Object> bundle = new HashMap<>(config.additionalProperties());\n        bundle.put(\"apiPackage\", config.apiPackage());\n","sourceCodeStart":1135,"sourceCodeEnd":1171,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L1135-L1171","documentation":"After the user's supporting files, DefaultGenerator itself emits a default .openapi-generator-ignore (from a bundled template) when: openapiGeneratorIgnoreList is unset/empty, the file does not already exist, and generateMetadata is true (default). An exception while writing it (IOException from processTemplateToFile) is wrapped with the target path. Same failure family as errors [5]/[6]: filesystem conditions on the output directory, plus template lookup of the bundled ignore template.","triggerScenarios":"Fresh output directory that is unwritable or does not exist while generateMetadata is on; an existing process locking .openapi-generator-ignore on Windows; a --template-dir override that shadows the bundled ignore template path incorrectly; read-only container mounts.","commonSituations":"First run into a new output location on CI with wrong ownership; hardened environments where the output mount is read-only; users surprised that a default ignore file is written at all and whose tooling locks it immediately.","solutions":["Verify the output directory exists and is writable (mkdir -p; chmod/touch test) before generating.","Pre-create your own .openapi-generator-ignore at the output root - its presence sets shouldGenerate=false and skips the write entirely.","Disable metadata outputs if you do not want them: DefaultGenerator.setGenerateMetadata(false) programmatically (this also skips .openapi-generator/VERSION per error [12]).","On Windows, close editors/watchers holding the file; on CI, ensure the workspace user owns the output directory."],"exampleFix":"// before: relying on the default write into a possibly unwritable dir\n// after: pre-create the ignore file (skips the default write) or disable metadata\nDefaultGenerator generator = new DefaultGenerator();\ngenerator.setGenerateMetadata(false); // skips VERSION + default .openapi-generator-ignore","handlingStrategy":"validation","validationCode":"// Pre-create your own ignore file (its presence skips the default write)\nPath out = Path.of(config.outputFolder());\nFiles.createDirectories(out);\nPath ignore = out.resolve(\".openapi-generator-ignore\");\nif (!Files.exists(ignore)) {\n    Files.writeString(ignore, \"# managed by build\\n\");\n}\nif (!Files.isWritable(out)) throw new IllegalStateException(\"Output not writable: \" + out);","typeGuard":null,"tryCatchPattern":"try {\n    generator.opts(input).generate();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\".openapi-generator-ignore\")\n            && e.getCause() instanceof java.io.IOException) {\n        // pre-create the file or call setGenerateMetadata(false), then retry\n        throw new GenerationFailure(\"Cannot write default ignore file\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Commit a project .openapi-generator-ignore into the output folder layout so the default write never runs.","Call DefaultGenerator.setGenerateMetadata(false) when metadata files are unwanted.","Verify output directory writability as part of the generation script."],"tags":["openapi-generator","io","filesystem","ignore-file","permissions"],"backgroundTag":"file-write-permission","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}