alibaba/arthas · critical · IllegalStateException
Failed to create directory within ${TEMP_DIR_ATTEMPTS} attem
Error message
Failed to create directory within ${TEMP_DIR_ATTEMPTS} attempts (tried ${baseName}0 to ${baseName}${TEMP_DIR_ATTEMPTS-1}) What it means
createTempDir tries up to TEMP_DIR_ATTEMPTS (10000) mkdir() calls under java.io.tmpdir and throws this IllegalStateException if every attempt collides or fails. Arthas uses this temp dir to extract arthas-bin.zip before loading arthas-core.jar, so failure blocks the whole attach.
Source
Thrown at arthas-agent-attach/src/main/java/com/taobao/arthas/agent/attach/ArthasAgent.java:146
} catch (Throwable e) {
errorMessage = e.getMessage();
if (!slientInit) {
throw new IllegalStateException(e);
}
}
}
private static File createTempDir() {
File baseDir = new File(System.getProperty("java.io.tmpdir"));
String baseName = "arthas-" + System.currentTimeMillis() + "-";
for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) {
File tempDir = new File(baseDir, baseName + counter);
if (tempDir.mkdir()) {
return tempDir;
}
}
throw new IllegalStateException("Failed to create directory within " + TEMP_DIR_ATTEMPTS + " attempts (tried "
+ baseName + "0 to " + baseName + (TEMP_DIR_ATTEMPTS - 1) + ')');
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
View on GitHub (pinned to 21cf2e9ba5)
Solutions
- Ensure the java.io.tmpdir directory is writable and has free space/inodes.
- Set -Djava.io.tmpdir=/path/to/writable/dir to a known-good location.
- Relax SELinux/security-manager rules so the JVM can create directories under tmpdir.
Example fix
// before java ... -jar arthas // -> Failed to create directory within 10000 attempts // after java -Djava.io.tmpdir=/var/tmp/arthas -jar arthas
Defensive patterns
Strategy: validation
Validate before calling
java.io.File tmp = new java.io.File(System.getProperty("java.io.tmpdir"));
if (!tmp.canWrite()) throw new IllegalStateException("tmpdir not writable: " + tmp);
java.io.File probe = new java.io.File(tmp, ".arthas_probe");
if (!probe.mkdir()) throw new IllegalStateException("cannot mkdir in tmpdir");
probe.delete(); Prevention
- Set -Djava.io.tmpdir to a writable directory in containers.
- Ensure free space/inodes on the temp partition.
- Relax SELinux/security-manager rules for the JVM.
When it happens
Trigger: java.io.tmpdir is not writable, full, or on a read-only mount; a security manager or SELinux denies mkdir; the temp partition is out of inodes/space.
Common situations: Container with a read-only /tmp; disk full; restrictive pod security policy; tmpdir mounted noexec/nosuid with permission issues.
Related errors
- File '{}' cannot be written to
- Directory '{}' could not be created
- can not find arthas-core.jar under arthasHome: ${arthasHome}
- File '{file}' cannot be written to
- Directory '{parent}' could not be created
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/81a3054ba11f191a.
Report an issue: GitHub.