{"record":{"id":"da9cc85cca286520","repo":"OpenAPITools/openapi-generator","slug":"could-not-generate-supporting-file-versionmetada","errorCode":null,"errorMessage":"Could not generate supporting file '{versionMetadata}'","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":1986,"sourceCode":"    /**\n     * Generates a file at .openapi-generator/VERSION to track the version of user's latest run.\n     *\n     * @param files The list tracking generated files\n     */\n    private void generateVersionMetadata(List<File> files) {\n        String versionMetadata = config.outputFolder() + File.separator + METADATA_DIR + File.separator + config.getVersionMetadataFilename();\n        if (generateMetadata) {\n            File versionMetadataFile = new File(versionMetadata);\n            try {\n                File written = this.templateProcessor.writeToFile(versionMetadata, (ImplementationVersion.read() + \"\\n\").getBytes(StandardCharsets.UTF_8));\n                if (written != null) {\n                    files.add(versionMetadataFile);\n                    if (config.isEnablePostProcessFile() && !dryRun) {\n                        config.postProcessFile(written, \"openapi-generator-version\");\n                    }\n                }\n            } catch (IOException e) {\n                throw new RuntimeException(\"Could not generate supporting file '\" + versionMetadata + \"'\", e);\n            }\n        } else {\n            Path metadata = java.nio.file.Paths.get(versionMetadata);\n            this.templateProcessor.skip(metadata, \"Skipped by generateMetadata option supplied by user.\");\n        }\n    }\n\n    private Path absPath(File input) {\n        // intentionally creates a new absolute path instance, disconnected from underlying FileSystem provider of File\n        return java.nio.file.Paths.get(input.getAbsolutePath());\n    }\n\n    /**\n     * Generates a file at .openapi-generator/FILES to track the files created by the user's latest run.\n     * This is ideal for CI and regeneration of code without stale/unused files from older generations.\n     *\n     * @param files The list tracking generated files\n     */","sourceCodeStart":1968,"sourceCodeEnd":2004,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L1968-L2004","documentation":"generateVersionMetadata (line 1973) writes <outputFolder>/.openapi-generator/<versionMetadataFilename> containing the generator's implementation version (used by later runs to detect version drift of generated code). When generateMetadata is true (default) and the write fails with IOException, it is wrapped with this message naming the target path. Like errors [5]/[7] the causes are filesystem ones, plus the specific case of a directory already existing where the VERSION file must be written.","triggerScenarios":"Output folder unwritable or absent; a directory named .openapi-generator/VERSION (or a conflicting path segment) already present from a corrupted previous run; read-only container mounts; antivirus/file-watcher locks on Windows; ENOSPC.","commonSituations":"CI workspaces with wrong ownership; Docker runs with read-only output volumes; stale output trees from interrupted earlier runs leaving half-created metadata paths; shared agents with disk quotas.","solutions":["Check the printed path: verify its parent directories are writable and that no DIRECTORY occupies the VERSION file's path (rm -rf the stale .openapi-generator dir if corrupted).","Generate into a clean output directory to rule out leftovers from previous runs.","If you intentionally run with metadata disabled, confirm it is actually off - use DefaultGenerator.setGenerateMetadata(false) (also stops the default .openapi-generator-ignore of error [7]) rather than deleting the file afterwards.","Verify disk space and mount read/write flags in containerized environments."],"exampleFix":"# before: stale/corrupt metadata dir blocks the write\n# after: clean the metadata directory and regenerate\nrm -rf out/.openapi-generator && openapi-generator generate -g java -i api.yaml -o out","handlingStrategy":"validation","validationCode":"// Pre-flight the metadata path: writable, and not blocked by a directory\nPath out = Path.of(config.outputFolder());\nPath version = out.resolve(\".openapi-generator\")\n                .resolve(config.getVersionMetadataFilename());\nFiles.createDirectories(version.getParent());\nif (Files.exists(version) && Files.isDirectory(version)) {\n    throw new IllegalStateException(\"Directory occupies VERSION path: \" + version);\n}\nif (!Files.isWritable(version.getParent())) {\n    throw new IllegalStateException(\"Metadata dir not writable: \" + version.getParent());\n}","typeGuard":null,"tryCatchPattern":"try {\n    generator.opts(input).generate();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\".openapi-generator\")\n            && e.getCause() instanceof java.io.IOException) {\n        // clean out/.openapi-generator and retry once into a clean output dir\n        throw new GenerationFailure(\"VERSION metadata unwritable\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Generate into a clean output directory each build (or clean out/.openapi-generator).","Call setGenerateMetadata(false) when you do not consume version metadata.","Check read/write mount flags for containerized generation output volumes."],"tags":["openapi-generator","io","filesystem","metadata","permissions"],"backgroundTag":"file-write-permission","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}