OpenAPITools/openapi-generator · error · RuntimeException
Failed to generate .openapi-generator-ignore when the option
Error message
Failed to generate .openapi-generator-ignore when the option `openapiGeneratorIgnoreList` is enabled:
What it means
DefaultGenerator.generateOpenapiGeneratorIgnoreFile (line 1023) runs when the openapiGeneratorIgnoreList option is non-empty: it writes a .openapi-generator-ignore file containing the user's entries, then rebuilds the ignore processor from it. The catch of IOException from Files.newBufferedWriter/write/close is rethrown with this message. This is virtually always a filesystem condition, not a spec problem: the output directory does not exist, is not writable, the disk is full, or the file is locked by another process.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java:1084
"#docs/*.md",
"# Then explicitly reverse the ignore rule for a single file:",
"#!docs/README.md",
"",
"# The following entries are pre-populated based on the input obtained via",
"# the option `openapiGeneratorIgnoreList` (--openapi-generator-ignore-list in CLI for example).",
"");
Writer fileWriter = Files.newBufferedWriter(ignoreFile.toPath(), StandardCharsets.UTF_8);
fileWriter.write(header);
// add entries provided by the users
for (String entry : config.getOpenapiGeneratorIgnoreList()) {
fileWriter.write(entry);
fileWriter.write("\n");
}
fileWriter.close();
// re-create ignore processor based on the newly-created .openapi-generator-ignore
this.ignoreProcessor = new CodegenIgnoreProcessor(ignoreFile);
} catch (IOException e) {
throw new RuntimeException("Failed to generate .openapi-generator-ignore when the option `openapiGeneratorIgnoreList` is enabled: ", e);
}
}
private void generateSupportingFiles(List<File> files, Map<String, Object> bundle) {
if (!generateSupportingFiles) {
// TODO: process these anyway and report via dryRun?
LOGGER.info("Skipping generation of supporting files.");
return;
}
Set<String> supportingFilesToGenerate = getPropertyAsSet(CodegenConstants.SUPPORTING_FILES);
for (SupportingFile support : config.supportingFiles()) {
try {
String outputFolder = config.outputFolder();
if (StringUtils.isNotEmpty(support.getFolder())) {
outputFolder += File.separator + support.getFolder();
}
File of = new File(outputFolder);View on GitHub (pinned to fcec517be3)
Solutions
- Ensure the output directory exists and is writable by the generating process (mkdir -p <out>; ls -ld <out>) before running.
- Close any editor/IDE/antivirus holding .openapi-generator-ignore open, or generate into a fresh output directory (-o /tmp/fresh-out) to confirm.
- Check disk space (df -h) and mount options (read-only volumes) if running in a container.
- If the ignore list is not actually needed, drop the openapiGeneratorIgnoreList option so the default ignore-file path (error [7]) or none applies instead.
Example fix
# before openapi-generator generate -g java -i api.yaml -o out \ --additional-properties openapiGeneratorIgnoreList=src/main/old/ # after: pre-create and verify the output directory first mkdir -p out && openapi-generator generate -g java -i api.yaml -o out \ --additional-properties openapiGeneratorIgnoreList=src/main/old/
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight the output directory before enabling openapiGeneratorIgnoreList
Path out = Path.of(config.outputFolder());
Files.createDirectories(out);
Path ignore = out.resolve(".openapi-generator-ignore");
if (Files.exists(ignore) && !Files.isWritable(ignore)) {
throw new IllegalStateException("Ignore file not writable: " + ignore);
}
if (!Files.isWritable(out)) {
throw new IllegalStateException("Output dir 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) {
// filesystem condition: surface actionable message, do not retry blindly
throw new GenerationFailure("Cannot write ignore file - check output dir permissions", e.getCause());
}
throw e;
} Prevention
- Create and permission the output directory in the build script before generation.
- On CI, write output to a directory the build user owns.
- Close/stop file watchers that lock .openapi-generator-ignore on Windows.
When it happens
Trigger: Setting openapiGeneratorIgnoreList (e.g. --additional-properties openapiGeneratorIgnoreList=<entries>, or config.setOpenapiGeneratorIgnoreList(...)) while the configured output folder does not exist or is read-only; the target .openapi-generator-ignore being held open by an editor/IDE/antivirus on Windows; generating into a read-only Docker volume; ENOSPC.
Common situations: CI pipelines generating into a workspace owned by another user; containerized runs with a read-only bind mount for the output; local runs where the previous output folder is open in a file watcher; disk-full conditions on shared agents.
Related errors
- Could not generate supporting file '{ignoreFileNameTarget}'
- 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/19bd2f4d052af8ab.
Report an issue: GitHub.