{"record":{"id":"bf08f33f29ff406b","repo":"gradle/gradle","slug":"failed-to-clean-up-output-files-for-s","errorCode":null,"errorMessage":"Failed to clean up output files for %s","messagePattern":"Failed to clean up output files for (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"platforms/core-execution/execution/src/main/java/org/gradle/internal/execution/steps/RemovePreviousOutputsStep.java","lineNumber":103,"sourceCode":"                            outputDirectoriesToPreserve.add(root);\n                            break;\n                        default:\n                            throw new AssertionError();\n                    }\n                }\n            });\n            OutputsCleaner cleaner = new OutputsCleaner(\n                deleter,\n                file -> true,\n                dir -> !outputDirectoriesToPreserve.contains(dir)\n            );\n            for (FileSystemSnapshot snapshot : previousOutputs.getOutputFilesProducedByWork().values()) {\n                try {\n                    // Previous outputs can be in a different place than the current outputs\n                    outputChangeListener.invalidateCachesFor(SnapshotUtil.rootIndex(snapshot).keySet());\n                    cleaner.cleanupOutputs(snapshot);\n                } catch (IOException e) {\n                    throw new UncheckedIOException(\"Failed to clean up output files for \" + work.getDisplayName(), e);\n                }\n            }\n        });\n    }\n\n    private void cleanupExclusivelyOwnedOutputs(MutableBeforeExecutionContext context, UnitOfWork work) {\n        work.visitOutputs(context.getWorkspace(), new OutputVisitor() {\n            @Override\n            public void visitOutputProperty(String propertyName, TreeType type, OutputFileValueSupplier value) {\n                File root = value.getValue();\n                if (root.exists()) {\n                    try {\n                        switch (type) {\n                            case FILE:\n                                deleter.delete(root);\n                                break;\n                            case DIRECTORY:\n                                deleter.ensureEmptyDirectory(root);","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/core-execution/execution/src/main/java/org/gradle/internal/execution/steps/RemovePreviousOutputsStep.java#L85-L121","documentation":"Error \"Failed to clean up output files for %s\" thrown in gradle/gradle.","triggerScenarios":"Thrown at platforms/core-execution/execution/src/main/java/org/gradle/internal/execution/steps/RemovePreviousOutputsStep.java:103 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Removing stale output files failed. Check file permissions/locks on the output directories; see the nested cause."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}