iBotPeaches/Apktool · error · BrutException

Could not create tmp dir

Error message

Could not create tmp dir

What it means

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.

Source

Thrown at brut.j.util/src/main/java/brut/util/OS.java:191

            return null;
        }
    }

    public static File createTempDirectory() throws BrutException {
        try {
            File tmp = File.createTempFile("BRUT", null);
            tmp.deleteOnExit();

            if (!tmp.delete()) {
                throw new BrutException("Could not delete tmp file: " + tmp.getAbsolutePath());
            }
            if (!tmp.mkdir()) {
                throw new BrutException("Could not create tmp dir: " + tmp.getAbsolutePath());
            }

            return tmp;
        } catch (IOException ex) {
            throw new BrutException("Could not create tmp dir", ex);
        }
    }

    private static class StreamForwarder extends Thread {
        private final InputStream mIn;
        private final String mType;

        public StreamForwarder(InputStream in, String type) {
            mIn = in;
            mType = type;
        }

        @Override
        public void run() {
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(mIn))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    if (mType.equals("OUTPUT")) {

View on GitHub (pinned to 79b63384d7)

Solutions

  1. Free space or fix permissions on the temp volume: df <tmpdir>, chmod/ownership check
  2. Point the JVM at a writable temp dir: -Djava.io.tmpdir=/path/to/dir (or fix the TMPDIR env var) — ensure the directory exists
  3. In containers, mount a writable tmpfs at /tmp or set java.io.tmpdir to an emptyDir/volume
  4. Read ex.getCause() message to confirm which failure it is (ENOSPC vs. EACCES vs. ENOENT) before changing anything

Example fix

# before
java -jar apktool.jar d app.apk   # ENOSPC / permission on /tmp

# after
mkdir -p /var/tmp/build && df -h /var/tmp
java -Djava.io.tmpdir=/var/tmp/build -jar apktool.jar d app.apk
Defensive patterns

Strategy: fallback

Validate before calling

Path tmp = Paths.get(System.getProperty("java.io.tmpdir"));
if (!Files.isDirectory(tmp) || !Files.isWritable(tmp)) {
    throw new IllegalStateException("tmpdir unusable: " + tmp);
}
// only then: OS.createTempDirectory();

Try / catch

try {
    dir = OS.createTempDirectory();
} catch (BrutException e) {
    if (e.getCause() instanceof IOException) {
        dir = fallbackDir(); // e.g. Files.createTempDirectory(Paths.get("/var/tmp"), "BRUT").toFile()
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14). Data as JSON: /api/errors/be75e9b9fe4671c9. Report an issue: GitHub.