iBotPeaches/Apktool · warning · BrutException
Could not delete tmp file:
Error message
Could not delete tmp file:
What it means
Thrown by OS.createTempDirectory when File.createTempFile('BRUT', null) succeeds but the immediate tmp.delete() on the just-created file returns false. The method's contract is: create a placeholder file, delete it, then mkdir the directory in its place. A false from delete() means something else holds or recreated the file — typically antivirus software on Windows, or a race with another process scanning java.io.tmpdir.
Source
Thrown at brut.j.util/src/main/java/brut/util/OS.java:183
process.waitFor(15, TimeUnit.SECONDS);
executor.shutdownNow();
if (!executor.awaitTermination(5, TimeUnit.SECONDS)) {
Log.w(TAG, "Stream collector did not terminate.");
}
return collector.get();
} catch (IOException | InterruptedException ignored) {
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;View on GitHub (pinned to 79b63384d7)
Solutions
- Add an AV exclusion for the java.io.tmpdir / build directory, or switch AV to on-access scan on close
- Point java.io.tmpdir to a local, non-scanned directory: -Djava.io.tmpdir=/var/tmp/mybuild
- Retry once after a short delay — the lock is usually transient
- Replace the pattern in your own code: Files.createTempDirectory("BRUT") creates the directory atomically without the delete-then-mkdir dance
Example fix
// before (library internals)
File tmp = File.createTempFile("BRUT", null);
tmp.delete(); // false under AV lock -> BrutException
// after (your own equivalent, avoids the failure mode)
Path tmp = Files.createTempDirectory("BRUT");
File dir = tmp.toFile(); Defensive patterns
Strategy: retry
Try / catch
File dir = null;
for (int i = 0; i < 2 && dir == null; i++) {
try {
dir = OS.createTempDirectory();
} catch (BrutException e) {
if (i == 1 || !e.getMessage().startsWith("Could not delete tmp file")) throw e;
}
} Prevention
- Exclude the build/temp directories from real-time antivirus scanning on Windows
- Set -Djava.io.tmpdir to a local fast disk, never a network share
- Prefer Files.createTempDirectory in your own code — it skips the delete-then-mkdir race entirely
When it happens
Trigger: OS.createTempDirectory() on systems where the freshly created temp file cannot be deleted: real-time antivirus holding an exclusive handle (Windows Defender, corporate AV), NFS-mounted tmpdir with delayed attribute caching, or a file watcher recreating/locking files in the temp directory.
Common situations: Windows workstations with aggressive antivirus scanning temp files the instant they appear; corporate environments with endpoint protection; tmpdir pointed at a network share (-Djava.io.tmpdir); CI agents where other jobs race through a shared temp dir.
Related errors
- Could not create tmp dir:
- Could not create tmp dir
- Absolute paths are not allowed
- Path traverses outside the base directory
- Could not move file:
AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14).
Data as JSON: /api/errors/deb5919a7bfff65f.
Report an issue: GitHub.