gradle/gradle · error · UncheckedIOException

Failed to clean up output files for %s

Error message

Failed to clean up output files for %s

What it means

Error "Failed to clean up output files for %s" thrown in gradle/gradle.

Source

Thrown at platforms/core-execution/execution/src/main/java/org/gradle/internal/execution/steps/RemovePreviousOutputsStep.java:103

                            outputDirectoriesToPreserve.add(root);
                            break;
                        default:
                            throw new AssertionError();
                    }
                }
            });
            OutputsCleaner cleaner = new OutputsCleaner(
                deleter,
                file -> true,
                dir -> !outputDirectoriesToPreserve.contains(dir)
            );
            for (FileSystemSnapshot snapshot : previousOutputs.getOutputFilesProducedByWork().values()) {
                try {
                    // Previous outputs can be in a different place than the current outputs
                    outputChangeListener.invalidateCachesFor(SnapshotUtil.rootIndex(snapshot).keySet());
                    cleaner.cleanupOutputs(snapshot);
                } catch (IOException e) {
                    throw new UncheckedIOException("Failed to clean up output files for " + work.getDisplayName(), e);
                }
            }
        });
    }

    private void cleanupExclusivelyOwnedOutputs(MutableBeforeExecutionContext context, UnitOfWork work) {
        work.visitOutputs(context.getWorkspace(), new OutputVisitor() {
            @Override
            public void visitOutputProperty(String propertyName, TreeType type, OutputFileValueSupplier value) {
                File root = value.getValue();
                if (root.exists()) {
                    try {
                        switch (type) {
                            case FILE:
                                deleter.delete(root);
                                break;
                            case DIRECTORY:
                                deleter.ensureEmptyDirectory(root);

View on GitHub (pinned to 534f27719b)

Solutions

  1. Removing stale output files failed. Check file permissions/locks on the output directories; see the nested cause.

When it happens

Trigger: Thrown at platforms/core-execution/execution/src/main/java/org/gradle/internal/execution/steps/RemovePreviousOutputsStep.java:103 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/bf08f33f29ff406b. Report an issue: GitHub.