{"record":{"id":"b10153a736993b6d","repo":"skylot/jadx","slug":"failed-to-write-caches-file","errorCode":null,"errorMessage":"Failed to write caches file","messagePattern":"Failed to write caches file","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-gui/src/main/java/jadx/gui/cache/manager/CacheManager.java","lineNumber":220,"sourceCode":"\t\tif (Utils.isEmpty(list)) {\n\t\t\treturn new HashMap<>();\n\t\t}\n\t\tMap<String, CacheEntry> map = new HashMap<>(list.size());\n\t\tfor (CacheEntry entry : list) {\n\t\t\tmap.put(entry.getProject(), entry);\n\t\t}\n\t\treturn map;\n\t}\n\n\tprivate synchronized void saveCaches(Map<String, CacheEntry> map) {\n\t\tList<CacheEntry> list = new ArrayList<>(map.values());\n\t\tCollections.sort(list);\n\t\tString json = GSON.toJson(list, CACHES_TYPE);\n\t\ttry {\n\t\t\tFiles.writeString(JadxFiles.CACHES_LIST, json, StandardCharsets.UTF_8,\n\t\t\t\t\tStandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to write caches file\", e);\n\t\t}\n\t}\n\n\t/**\n\t * Load caches info from recent projects list.\n\t * Help for initial migration.\n\t */\n\tprivate Map<String, CacheEntry> initFromRecentProjects() {\n\t\ttry {\n\t\t\tMap<String, CacheEntry> map = new HashMap<>();\n\t\t\tlong t = System.currentTimeMillis();\n\t\t\tfor (Path project : settings.getRecentProjects()) {\n\t\t\t\ttry {\n\t\t\t\t\tProjectData data = JadxProject.loadProjectData(project);\n\t\t\t\t\tString cacheDir = data.getCacheDir();\n\t\t\t\t\tif (cacheDir == null) {\n\t\t\t\t\t\t// no cache dir, ignore\n\t\t\t\t\t\tcontinue;","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-gui/src/main/java/jadx/gui/cache/manager/CacheManager.java#L202-L238","documentation":"CacheManager.saveCaches serializes the in-memory cache entry list to JSON and writes it to the CACHES_LIST file with CREATE+TRUNCATE_EXISTING. If writing fails (disk full, permission denied, I/O error), a JadxRuntimeException wraps the cause.","triggerScenarios":"saveCaches() builds a sorted list of CacheEntry, serializes via Gson, and calls Files.writeString. Any exception during write triggers the error. Called during cache lifecycle updates (adding, removing, or verifying cache entries).","commonSituations":"Disk full or quota exceeded in the user configuration directory. Permission denied on the caches list file. Concurrent write from two jadx instances. Antivirus or sync software locking the file. Read-only filesystem.","solutions":["Free disk space in the user home / config directory","Check write permissions on the jadx configuration directory","Ensure only one jadx instance is running","Add an antivirus/sync exclusion for the jadx config directory","Manually delete the caches list file to force recreation"],"exampleFix":"// Clear the caches list to allow clean recreation:\n// rm ~/.jadx/caches.json  (path varies by OS / config)\n// Restart jadx — it will recreate the file.","handlingStrategy":"try-catch","validationCode":"// Verify config dir is writable before saving\nPath cachesList = JadxFiles.CACHES_LIST;\nFiles.createDirectories(cachesList.getParent());\nif (!Files.isWritable(cachesList.getParent())) { throw new IllegalStateException(\"Cannot write caches file\"); }","typeGuard":null,"tryCatchPattern":"try {\n    cacheManager.saveCaches(map);\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().contains(\"Failed to write caches file\")) {\n        LOG.warn(\"Non-fatal: could not persist cache list\", e);\n        // in-memory state is still valid\n    }\n}","preventionTips":["Keep the config directory writable and on local storage","Run a single jadx instance","Treat caches-list write failure as non-fatal"],"tags":["cache","io","filesystem","serialization","jadx-gui"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}