OpenAPITools/openapi-generator · error · RuntimeException
Could not generate supporting file '{ignoreFileNameTarget}'
Error message
Could not generate supporting file '{ignoreFileNameTarget}' What it means
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.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java:1153
if (config.openapiGeneratorIgnoreList() == null || config.openapiGeneratorIgnoreList().isEmpty()) {
final String openapiGeneratorIgnore = ".openapi-generator-ignore";
String ignoreFileNameTarget = config.outputFolder() + File.separator + openapiGeneratorIgnore;
File ignoreFile = new File(ignoreFileNameTarget);
if (generateMetadata) {
try {
boolean shouldGenerate = !ignoreFile.exists();
if (shouldGenerate && supportingFilesToGenerate != null && !supportingFilesToGenerate.isEmpty()) {
shouldGenerate = supportingFilesToGenerate.contains(openapiGeneratorIgnore);
}
File written = processTemplateToFile(bundle, openapiGeneratorIgnore, ignoreFileNameTarget, shouldGenerate, CodegenConstants.SUPPORTING_FILES);
if (written != null) {
files.add(written);
if (config.isEnablePostProcessFile() && !dryRun) {
config.postProcessFile(written, "openapi-generator-ignore");
}
}
} catch (Exception e) {
throw new RuntimeException("Could not generate supporting file '" + ignoreFileNameTarget + "'", e);
}
} else {
this.templateProcessor.skip(ignoreFile.toPath(), "Skipped by generateMetadata option supplied by user.");
}
}
generateVersionMetadata(files);
}
Map<String, Object> buildSupportFileBundle(List<OperationsMap> allOperations, List<ModelMap> allModels, List<ModelMap> aliasModels) {
return this.buildSupportFileBundle(allOperations, allModels, aliasModels, null);
}
Map<String, Object> buildSupportFileBundle(List<OperationsMap> allOperations, List<ModelMap> allModels, List<ModelMap> aliasModels, List<WebhooksMap> allWebhooks) {
Map<String, Object> bundle = new HashMap<>(config.additionalProperties());
bundle.put("apiPackage", config.apiPackage());
View on GitHub (pinned to fcec517be3)
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.
Example fix
// before: relying on the default write into a possibly unwritable dir // after: pre-create the ignore file (skips the default write) or disable metadata DefaultGenerator generator = new DefaultGenerator(); generator.setGenerateMetadata(false); // skips VERSION + default .openapi-generator-ignore
Defensive patterns
Strategy: validation
Validate before calling
// Pre-create your own ignore file (its presence skips the default write)
Path out = Path.of(config.outputFolder());
Files.createDirectories(out);
Path ignore = out.resolve(".openapi-generator-ignore");
if (!Files.exists(ignore)) {
Files.writeString(ignore, "# managed by build\n");
}
if (!Files.isWritable(out)) throw new IllegalStateException("Output not writable: " + out); Try / catch
try {
generator.opts(input).generate();
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains(".openapi-generator-ignore")
&& e.getCause() instanceof java.io.IOException) {
// pre-create the file or call setGenerateMetadata(false), then retry
throw new GenerationFailure("Cannot write default ignore file", e.getCause());
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to generate .openapi-generator-ignore when the option
- Could not generate supporting file '{versionMetadata}'
- Failed to create the folder " + parent.getAbsolutePath() + "
- Could not generate model '{modelName}'
- Could not generate supporting file '{support}'
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/faa4ccaecf2749f3.
Report an issue: GitHub.