{"record":{"id":"be75e9b9fe4671c9","repo":"iBotPeaches/Apktool","slug":"could-not-create-tmp-dir-be75e9","errorCode":null,"errorMessage":"Could not create tmp dir","messagePattern":"Could not create tmp dir","errorType":"exception","errorClass":"BrutException","httpStatus":null,"severity":"error","filePath":"brut.j.util/src/main/java/brut/util/OS.java","lineNumber":191,"sourceCode":"            return null;\n        }\n    }\n\n    public static File createTempDirectory() throws BrutException {\n        try {\n            File tmp = File.createTempFile(\"BRUT\", null);\n            tmp.deleteOnExit();\n\n            if (!tmp.delete()) {\n                throw new BrutException(\"Could not delete tmp file: \" + tmp.getAbsolutePath());\n            }\n            if (!tmp.mkdir()) {\n                throw new BrutException(\"Could not create tmp dir: \" + tmp.getAbsolutePath());\n            }\n\n            return tmp;\n        } catch (IOException ex) {\n            throw new BrutException(\"Could not create tmp dir\", ex);\n        }\n    }\n\n    private static class StreamForwarder extends Thread {\n        private final InputStream mIn;\n        private final String mType;\n\n        public StreamForwarder(InputStream in, String type) {\n            mIn = in;\n            mType = type;\n        }\n\n        @Override\n        public void run() {\n            try (BufferedReader reader = new BufferedReader(new InputStreamReader(mIn))) {\n                String line;\n                while ((line = reader.readLine()) != null) {\n                    if (mType.equals(\"OUTPUT\")) {","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.j.util/src/main/java/brut/util/OS.java#L173-L209","documentation":"Thrown by OS.createTempDirectory when File.createTempFile('BRUT', null) itself throws IOException — no temp file could be created at all. The JVM reports the underlying reason (no space left on device, permission denied, or tmpdir does not exist). Unlike its sibling errors, this one carries no path in the message; look at the cause IOException for details.","triggerScenarios":"OS.createTempDirectory() when java.io.tmpdir is unwritable, full, missing, or not a directory — e.g. docker image without /tmp, disk-full CI runner, TMPDIR env var pointing to a deleted directory, or read-only root filesystem.","commonSituations":"Docker/OCI containers running with a read-only root or missing /tmp; CI runners exhausting disk space; TMPDIR pointing at a path deleted by an earlier cleanup step; security-hardened JVMs denying write access to the default temp location.","solutions":["Free space or fix permissions on the temp volume: df <tmpdir>, chmod/ownership check","Point the JVM at a writable temp dir: -Djava.io.tmpdir=/path/to/dir (or fix the TMPDIR env var) — ensure the directory exists","In containers, mount a writable tmpfs at /tmp or set java.io.tmpdir to an emptyDir/volume","Read ex.getCause() message to confirm which failure it is (ENOSPC vs. EACCES vs. ENOENT) before changing anything"],"exampleFix":"# before\njava -jar apktool.jar d app.apk   # ENOSPC / permission on /tmp\n\n# after\nmkdir -p /var/tmp/build && df -h /var/tmp\njava -Djava.io.tmpdir=/var/tmp/build -jar apktool.jar d app.apk","handlingStrategy":"fallback","validationCode":"Path tmp = Paths.get(System.getProperty(\"java.io.tmpdir\"));\nif (!Files.isDirectory(tmp) || !Files.isWritable(tmp)) {\n    throw new IllegalStateException(\"tmpdir unusable: \" + tmp);\n}\n// only then: OS.createTempDirectory();","typeGuard":null,"tryCatchPattern":"try {\n    dir = OS.createTempDirectory();\n} catch (BrutException e) {\n    if (e.getCause() instanceof IOException) {\n        dir = fallbackDir(); // e.g. Files.createTempDirectory(Paths.get(\"/var/tmp\"), \"BRUT\").toFile()\n    } else throw e;\n}","preventionTips":["Fail fast at startup if java.io.tmpdir is not a writable directory","In containers, mount writable storage at /tmp or set -Djava.io.tmpdir explicitly","Monitor disk space on the temp volume; ENOSPC is the most common cause of createTempFile IOExceptions"],"tags":["filesystem","temp-files","disk-full","environment","java"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}