{"record":{"id":"f47fed39a4681064","repo":"elastic/elasticsearch","slug":"failed-to-delete-some-files-files","errorCode":null,"errorMessage":"Failed to delete some files:\n\n{files}","messagePattern":"Failed to delete some files:\n\n(.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"warning","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/PruneChangelogsTask.java","lineNumber":113,"sourceCode":"        }\n\n        final Set<File> filesToDelete = allFilesInCheckout.stream()\n            .filter(each -> earlierFiles.contains(each.getName()))\n            .collect(Collectors.toCollection(TreeSet::new));\n\n        if (filesToDelete.isEmpty()) {\n            LOGGER.warn(\"No files need to be deleted.\");\n            return;\n        }\n\n        LOGGER.warn(\"The following changelog files will be deleted:\");\n        LOGGER.warn(\"\");\n        filesToDelete.forEach(file -> LOGGER.warn(\"\\t{}\", rootDir.relativize(file.toPath())));\n\n        final Set<File> failedToDelete = deleteHelper.deleteFiles(filesToDelete);\n\n        if (failedToDelete.isEmpty() == false) {\n            throw new GradleException(\n                \"Failed to delete some files:\\n\\n\"\n                    + failedToDelete.stream().map(file -> \"\\t\" + rootDir.relativize(file.toPath())).collect(Collectors.joining(\"\\n\"))\n                    + \"\\n\"\n            );\n        }\n    }\n\n    /**\n     * Find the releases prior to the supplied version, and find the changelog files in those releases by inspecting the\n     * git trees at each tag.\n     * <p>\n     * If the supplied version is the very first in a new major series, then the method will look tag in the previous\n     * major series. Otherwise, all git tags in the current major series will be inspected.\n     *\n     * @param gitWrapper used for git operations\n     * @param version the git history is inspected relative to this version\n     * @return filenames for changelog files in previous releases, without any path\n     */","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/PruneChangelogsTask.java#L95-L131","documentation":"Thrown by PruneChangelogsTask after attempting to delete a set of changelog files deemed safe to remove. The deleteHelper.deleteFiles call returns the subset it could not delete; if that set is non-empty, the task lists the survivors (relative to rootDir) and throws a GradleException so the operator knows which files remain.","triggerScenarios":"The task computed filesToDelete (changelogs already represented elsewhere/released), called deleteFiles, and some deletions failed. Typical causes: a file is locked by another process, has read-only permissions, or the JVM lacks delete permission on the parent directory.","commonSituations":"An IDE or file watcher holding a handle on a changelog YAML on Windows/locked fs; read-only file permissions from a git checkout or packaging step; another Gradle process or editor holding the file; running the prune task without write permission to the changelog tree.","solutions":["Close editors/IDEs and any process that may hold the listed files open, then re-run pruneChangelogs.","Check and fix permissions on the surviving files (e.g. chmod u+w) and their parent directories.","On Windows, ensure no file explorer/antivirus has the files locked.","Re-run the task; if specific files persistently fail, delete them manually and re-run to confirm the remainder succeed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Preflight: ensure files are deletable\nfor (File f : filesToDelete) {\n    if (f.exists() && f.canWrite() == false) f.setWritable(true);\n}","typeGuard":null,"tryCatchPattern":"Set<File> failed = deleteHelper.deleteFiles(filesToDelete);\nif (failed.isEmpty() == false) {\n    // close handles / fix perms, then retry once\n    failed.forEach(f -> f.setWritable(true));\n    failed = deleteHelper.deleteFiles(failed);\n    if (failed.isEmpty() == false) throw new GradleException(\"Failed to delete: \" + failed);\n}","preventionTips":["Close editors and file watchers before running pruneChangelogs.","Ensure changelog files are writable (chmod u+w).","On Windows, check for antivirus/explorer locks on YAML files."],"tags":["build","gradle","release","changelog","io","filesystem"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}