{"record":{"id":"d3d006e475a915d5","repo":"skylot/jadx","slug":"failed-to-create-temp-root-directory","errorCode":null,"errorMessage":"Failed to create temp root directory","messagePattern":"Failed to create temp root directory","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"jadx-commons/jadx-app-commons/src/main/java/jadx/commons/app/JadxTempFiles.java","lineNumber":30,"sourceCode":"\tpublic static Path getTempRootDir() {\n\t\treturn TEMP_ROOT_DIR;\n\t}\n\n\tprivate static Path createTempRootDir() {\n\t\ttry {\n\t\t\tString jadxTmpDir = System.getenv(\"JADX_TMP_DIR\");\n\t\t\tPath dir;\n\t\t\tif (jadxTmpDir != null) {\n\t\t\t\tPath customTmpRootDir = Paths.get(jadxTmpDir);\n\t\t\t\tFiles.createDirectories(customTmpRootDir);\n\t\t\t\tdir = Files.createTempDirectory(customTmpRootDir, JADX_TMP_INSTANCE_PREFIX);\n\t\t\t} else {\n\t\t\t\tdir = Files.createTempDirectory(JADX_TMP_INSTANCE_PREFIX);\n\t\t\t}\n\t\t\tdir.toFile().deleteOnExit();\n\t\t\treturn dir;\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Failed to create temp root directory\", e);\n\t\t}\n\t}\n}\n","sourceCodeStart":12,"sourceCodeEnd":34,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-commons/jadx-app-commons/src/main/java/jadx/commons/app/JadxTempFiles.java#L12-L34","documentation":"Thrown by JadxTempFiles (static init) as a RuntimeException wrapping any exception during temp root directory creation. It honors JADX_TMP_DIR (creating a temp instance dir under it) or falls back to the system temp dir; any failure is wrapped here.","triggerScenarios":"JADX_TMP_DIR set to a path where createDirectories or createTempDirectory fails; the system java.io.tmpdir is not writable; permission denied; disk full during init.","commonSituations":"Running jadx in a container/CI where /tmp is read-only or mounted with noexec/nodev; JADX_TMP_DIR pointing to a non-existent parent that cannot be created; temp filesystem full.","solutions":["Point JADX_TMP_DIR to a writable absolute directory.","Ensure java.io.tmpdir (system temp) is writable.","Free space on the temp filesystem.","Check container mount options for /tmp (remove ro/noexec if present)."],"exampleFix":"// before (read-only /tmp in container)\njadx input.apk\n// after\nJADX_TMP_DIR=/var/tmp/jadx jadx input.apk","handlingStrategy":"try-catch","validationCode":"String t = System.getenv(\"JADX_TMP_DIR\");\nif (t != null) {\n    Path p = Paths.get(t);\n    Files.createDirectories(p);\n    if (!Files.isWritable(p)) throw new IllegalStateException(\"JADX_TMP_DIR not writable: \" + t);\n} else {\n    Path sysTmp = Paths.get(System.getProperty(\"java.io.tmpdir\"));\n    if (!Files.isWritable(sysTmp)) throw new IllegalStateException(\"System temp not writable: \" + sysTmp);\n}","typeGuard":"public static boolean tmpWritable() {\n    try {\n        Path t = System.getenv(\"JADX_TMP_DIR\") != null ? Paths.get(System.getenv(\"JADX_TMP_DIR\")) : Paths.get(System.getProperty(\"java.io.tmpdir\"));\n        Files.createDirectories(t);\n        return Files.isWritable(t);\n    } catch (IOException e) { return false; }\n}","tryCatchPattern":"// Fires during static init of JadxTempFiles\ntry {\n    Class.forName(\"jadx.commons.app.JadxTempFiles\");\n} catch (ExceptionInInitializerError e) {\n    Throwable c = e.getCause();\n    if (c instanceof RuntimeException && c.getMessage().equals(\"Failed to create temp root directory\")) {\n        System.err.println(\"Set JADX_TMP_DIR to a writable dir. Cause: \" + c.getCause());\n        System.exit(1);\n    }\n    throw e;\n}","preventionTips":["In containers, mount /tmp writable or set JADX_TMP_DIR to a writable volume.","Avoid noexec/ro mounts on the temp directory.","Monitor free space on the temp filesystem."],"tags":["temp","init","environment","io","jadx"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}