{"record":{"id":"451a6b045bbc79f6","repo":"skylot/jadx","slug":"failed-to-update-temp-root-directory","errorCode":null,"errorMessage":"Failed to update temp root directory","messagePattern":"Failed to update temp root directory","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java","lineNumber":69,"sourceCode":"\n\tpublic static final String JADX_TMP_INSTANCE_PREFIX = \"jadx-instance-\";\n\tpublic static final String JADX_TMP_PREFIX = \"jadx-tmp-\";\n\n\tprivate static Path tempRootDir = createTempRootDir();\n\n\tprivate FileUtils() {\n\t\t// utility class\n\t}\n\n\tpublic static synchronized Path updateTempRootDir(Path newTempRootDir) {\n\t\ttry {\n\t\t\tmakeDirs(newTempRootDir);\n\t\t\tPath dir = Files.createTempDirectory(newTempRootDir, JADX_TMP_INSTANCE_PREFIX);\n\t\t\ttempRootDir = dir;\n\t\t\tdir.toFile().deleteOnExit();\n\t\t\treturn dir;\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to update temp root directory\", e);\n\t\t}\n\t}\n\n\tprivate static Path createTempRootDir() {\n\t\ttry {\n\t\t\tPath dir = Files.createTempDirectory(JADX_TMP_INSTANCE_PREFIX);\n\t\t\tdir.toFile().deleteOnExit();\n\t\t\treturn dir;\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to create temp root directory\", e);\n\t\t}\n\t}\n\n\tpublic static List<Path> listFiles(Path dir) {\n\t\ttry (Stream<Path> files = Files.list(dir)) {\n\t\t\treturn files.collect(Collectors.toList());\n\t\t} catch (IOException e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to list files in directory: \" + dir, e);","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java#L51-L87","documentation":"Thrown when FileUtils.updateTempRootDir fails to switch jadx's temp directory to a user-specified location. The method first calls makeDirs(newTempRootDir) (which can itself throw 'Can't create directory'), then Files.createTempDirectory inside it. A failure means either the target directory cannot be created/validated, or a unique temp subdirectory cannot be allocated within it.","triggerScenarios":"Calling FileUtils.updateTempRootDir(Path) where the path is read-only, the parent doesn't exist, disk is full, or the path points to a file instead of a directory. Also if makeDirs internally fails because mkdirs() returns false and isDirectory() is false.","commonSituations":"User sets -Djava.io.tmpdir or a jadx-specific temp dir option to a path on a read-only filesystem. Running in a sandboxed/containerized environment where the specified temp root is not writable. The path was valid at config time but a parent mount was removed before the call.","solutions":["Verify the candidate directory is writable before calling: Files.isWritable(newTempRootDir).","Ensure the parent path chain exists: Files.createDirectories(newTempRootDir).","Avoid pointing the temp root at a file or a symlink to a non-directory.","Check the JadxRuntimeException cause to distinguish mkdir failure from createTempDirectory failure."],"exampleFix":"// before\nFileUtils.updateTempRootDir(customTempDir);\n\n// after\nFiles.createDirectories(customTempDir);\nif (!Files.isWritable(customTempDir)) throw new IllegalStateException(\"temp dir not writable\");\nFileUtils.updateTempRootDir(customTempDir);","handlingStrategy":"validation","validationCode":"public static boolean isTempDirCandidate(Path dir) {\n    if (!Files.exists(dir)) {\n        try { Files.createDirectories(dir); } catch (IOException e) { return false; }\n    }\n    return Files.isDirectory(dir) && Files.isWritable(dir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    FileUtils.updateTempRootDir(customTempDir);\n} catch (JadxRuntimeException e) {\n    LOG.error(\"Cannot use temp dir {}: {}\", customTempDir, e.getCause().getMessage());\n    // fall back to default\n}","preventionTips":["Pre-validate the candidate directory is writable before switching the temp root.","Avoid pointing temp root at symlinks to non-directories or files.","Run with appropriate filesystem permissions in containerized environments."],"tags":["temp-dir","filesystem","permissions","jadx"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}