{"record":{"id":"4eb51c4d8ba37208","repo":"skylot/jadx","slug":"failed-to-create-temp-root-directory-4eb51c","errorCode":null,"errorMessage":"Failed to create temp root directory","messagePattern":"Failed to create temp root directory","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"critical","filePath":"jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java","lineNumber":79,"sourceCode":"\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);\n\t\t}\n\t}\n\n\tpublic static List<Path> listFiles(Path dir, Predicate<? super Path> filter) {\n\t\ttry (Stream<Path> files = Files.list(dir)) {\n\t\t\treturn files.filter(filter).collect(Collectors.toList());\n\t\t} catch (IOException e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to list files in directory: \" + dir, e);\n\t\t}\n\t}","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java#L61-L97","documentation":"Thrown from the static initializer (line 55: tempRootDir = createTempRootDir()) when Files.createTempDirectory(JADX_TMP_INSTANCE_PREFIX) fails. Because this runs at class-load time, the failure manifests as an ExceptionInInitializerError wrapping this JadxRuntimeException. It means the OS default temp directory (java.io.tmpdir, typically /tmp) is not writable or cannot allocate a new directory.","triggerScenarios":"Loading FileUtils for the first time when java.io.tmpdir is unwritable, does not exist, is full (no inodes), or the process lacks permission. The JVM's -Djava.io.tmpdir was set to an invalid path. This fires at class initialization, so it can crash the entire application before any user code runs.","commonSituations":"Running jadx in a locked-down container or CI runner where /tmp is mounted read-only or tmpfs is exhausted. Setting -Djava.io.tmpdir to a path that doesn't exist. An inode-exhausted filesystem. SELinux/AppArmor denying directory creation under /tmp.","solutions":["Set -Djava.io.tmpdir to a known-writable directory: java -Djava.io.tmpdir=/path/to/writable/dir ...","Verify /tmp exists, is writable, and has free space/inodes: ls -ld /tmp && df -h /tmp && df -i /tmp.","If running in a container, mount a writable tmpfs or volume at /tmp.","Check OS-level security policy (SELinux/AppArmor) is not blocking directory creation."],"exampleFix":"// before — relies on default /tmp which may be unwritable\njava -jar jadx.jar input.apk\n\n// after — point tmpdir to a writable location\njava -Djava.io.tmpdir=/var/tmp/jadx -jar jadx.jar input.apk","handlingStrategy":"try-catch","validationCode":"// Cannot easily validate at runtime since this fires at class-load time.\n// Pre-launch check: verify java.io.tmpdir is writable before loading FileUtils.\npublic static void checkSystemTempDir() {\n    Path tmp = Path.of(System.getProperty(\"java.io.tmpdir\"));\n    if (!Files.isDirectory(tmp) || !Files.isWritable(tmp)) {\n        throw new IllegalStateException(\"java.io.tmpdir is not writable: \" + tmp);\n    }\n}","typeGuard":null,"tryCatchPattern":"// This fires as ExceptionInInitializerError at class load; catch at the outermost level.\ntry {\n    Class.forName(\"jadx.core.utils.files.FileUtils\");\n} catch (ExceptionInInitializerError e) {\n    if (e.getCause() instanceof JadxRuntimeException) {\n        System.err.println(\"Fatal: cannot create temp root. Set -Djava.io.tmpdir to a writable dir.\");\n        System.exit(1);\n    }\n}","preventionTips":["Always set -Djava.io.tmpdir to a known-writable directory in production deployments.","Verify /tmp is writable and has free space/inodes before launching jadx.","In containers, mount a writable volume at /tmp or configure tmpdir."],"tags":["startup","temp-dir","class-init","filesystem","permissions","jadx"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}