gradle/gradle · error · UncheckedIOException

Failed to hash {}

Error message

Failed to hash {}

What it means

DefaultClassSetAnalyzer hashes classpath entries for ABI analysis (compile avoidance / up-to-date checks). JarEntryVisitor.getHashCode wraps any IOException while reading a jar entry to hash it as UncheckedIOException('Failed to hash <entry>'), naming the offending file so it can be inspected.

Source

Thrown at platforms/jvm/language-java/src/main/java/org/gradle/api/internal/tasks/compile/incremental/classpath/DefaultClassSetAnalyzer.java:143

            }
        }

        protected abstract HashCode getHashCode(FileVisitDetails fileDetails);
    }

    private class JarEntryVisitor extends EntryVisitor {

        public JarEntryVisitor(ClassDependentsAccumulator accumulator, boolean abiOnly) {
            super(accumulator, abiOnly);
        }

        @Override
        protected HashCode getHashCode(FileVisitDetails fileDetails) {
            InputStream inputStream = fileDetails.open();
            try {
                return hasher.hash(inputStream);
            } catch (IOException e) {
                throw new UncheckedIOException("Failed to hash " + fileDetails, e);
            } finally {
                IoActions.closeQuietly(inputStream);
            }
        }
    }

    private class DirectoryEntryVisitor extends EntryVisitor {

        public DirectoryEntryVisitor(ClassDependentsAccumulator accumulator, boolean abiOnly) {
            super(accumulator, abiOnly);
        }

        @Override
        protected HashCode getHashCode(FileVisitDetails fileDetails) {
            return fileHasher.hash(fileDetails.getFile(), fileDetails.getSize(), fileDetails.getLastModified());
        }
    }

View on GitHub (pinned to 534f27719b)

Solutions

  1. Test the jar named in the message: unzip -t <jar> — if it fails, the artifact is corrupt
  2. Delete and re-fetch it: remove the module from ~/.gradle/caches/modules-2 or run ./gradlew --refresh-dependencies
  3. Stop concurrent processes sharing the same Gradle caches, or give each build its own GRADLE_USER_HOME
  4. On Windows, exclude the Gradle cache directories from antivirus scanning

Example fix

# before: reuse of a corrupt cached jar
# after
./gradlew --refresh-dependencies build
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: Compile-avoidance hashing walks the compile classpath and a jar entry cannot be opened/read: corrupted zip central directory, truncated jar from an interrupted download, file lock (Windows/AV), or a jar replaced on disk mid-build.

Common situations: Broken artifacts in ~/.gradle/caches or a local libs directory; NFS/network filesystems with flaky reads; two builds sharing one cache dir; antivirus locking jars on Windows.

Related errors


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