From 0d3049e60ec66bc9fd981af3f525bc713ba09e87 Mon Sep 17 00:00:00 2001 From: azad Date: Thu, 16 Jul 2026 20:38:03 +0000 Subject: [PATCH] Fix action cache cold start crash on empty output base The deleteUnrecognizedFiles method (backported from Bazel 9 in #41) calls cacheRoot.getDirectoryEntries() without checking if the action_cache directory exists. On a cold cache (fresh output base), the directory hasn't been created yet, causing an IOException: 'No such file or directory'. Bazel 7 doesn't have this issue because it lacks deleteUnrecognizedFiles. The fix adds an existence check at the top of the method, returning early if the directory doesn't exist yet (there are no files to clean up anyway). --- .../build/lib/actions/cache/CompactPersistentActionCache.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java b/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java index 810fa7c5b33f95..827a3357a6d389 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java +++ b/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java @@ -270,6 +270,9 @@ private static CompactPersistentActionCache create( *

Backported from https://github.com/bazelbuild/bazel/pull/27525 (Bazel 9.0.0). */ private static void deleteUnrecognizedFiles(Path cacheRoot) throws IOException { + if (!cacheRoot.exists()) { + return; + } Path indexFile = cacheRoot.getChild("filename_index_v" + VERSION + ".blaze"); Path indexJournalFile = cacheRoot.getChild("filename_index_v" + VERSION + ".journal"); ImmutableSet knownFiles =