{"record":{"id":"cf9be466a2364cee","repo":"gradle/gradle","slug":"failed-to-initialize-s","errorCode":null,"errorMessage":"Failed to initialize %s","messagePattern":"Failed to initialize (.+?)","errorType":"exception","errorClass":"CacheOpenException","httpStatus":null,"severity":"error","filePath":"platforms/core-execution/persistent-cache/src/main/java/org/gradle/cache/internal/FixedSharedModeCrossProcessCacheAccess.java","lineNumber":100,"sourceCode":"                            if (rebuild) {\n                                exclusiveLock.writeFile(new Runnable() {\n                                    @Override\n                                    public void run() {\n                                        initializationAction.initialize(acquiredExclusiveLock);\n                                    }\n                                });\n                            }\n                        }\n                    } finally {\n                        if (exclusiveLock != null) {\n                            exclusiveLock.close();\n                        }\n                    }\n                    fileLock = lockManager.lock(lockTarget, lockOptions, cacheDisplayName);\n                    rebuild = initializationAction.requiresInitialization(fileLock);\n                }\n                if (rebuild) {\n                    throw new CacheOpenException(String.format(\"Failed to initialize %s\", cacheDisplayName), latestException);\n                }\n            }\n            onOpenAction.accept(fileLock);\n        } catch (Exception e) {\n            if (fileLock != null) {\n                fileLock.close();\n            }\n            throw UncheckedException.throwAsUncheckedException(e);\n        }\n        this.fileLock = fileLock;\n    }\n\n    @Override\n    public void close() {\n        if (fileLock != null) {\n            try {\n                onCloseAction.accept(fileLock);\n                fileLock.close();","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/core-execution/persistent-cache/src/main/java/org/gradle/cache/internal/FixedSharedModeCrossProcessCacheAccess.java#L82-L118","documentation":"FixedSharedModeCrossProcessCacheAccess opens a cache under a cross-process lock and runs the initialization action once while holding the exclusive lock. If the action still reports that initialization is required afterwards, this CacheOpenException is thrown with the cache display name, carrying the last underlying failure as the cause. It means the cache could not be brought into a usable state.","triggerScenarios":"The initialization action throws repeatedly while the cache opens: unreadable or deleted cache directory, corrupted state/properties files, permission or disk problems while wiping or writing initial state.","commonSituations":"Corrupted cache after a crashed build, permission/ownership changes on the cache dir, mixed Gradle versions sharing one GRADLE_USER_HOME, full disk.","solutions":["Read the cause (latestException) in the stack trace; it names the real underlying failure","Run ./gradlew --stop, delete the affected cache directory, and retry the build","Fix ownership/permissions and free disk space on the cache volume","If caused by version mixing, separate GRADLE_USER_HOME per Gradle version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"File dir = new File(cacheDirPath);\nif (!Files.isReadable(dir.toPath()) || !Files.isWritable(dir.toPath())) {\n    throw new IllegalStateException(\"Cache directory not accessible: \" + dir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    cacheAccess.open(); // FixedSharedModeCrossProcessCacheAccess\n} catch (CacheOpenException e) {\n    Throwable root = e.getCause(); // 'latestException': the real init failure\n    // recover by invalidating the cache directory, then retry once\n}","preventionTips":["Keep cache directories local and writable","Stop daemons before manual cache maintenance","Run only one Gradle version per cache directory"],"tags":["gradle","persistent-cache","initialization","file-lock"],"backgroundTag":"cache-initialization-failed","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}