SonarSource/sonarqube · critical · IllegalStateException
Temp directory is not writable: %s
Error message
Temp directory is not writable: %s
What it means
MinimumViableSystem.checkWritableDir verifies a directory is writable by creating and deleting a temp file in it. If File.createTempFile throws IOException, the directory is not writable and an IllegalStateException is thrown.
Source
Thrown at server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java:47
import static org.sonar.process.FileUtils2.deleteQuietly;
public class MinimumViableSystem {
/**
* Verify that temp directory is writable
*/
public MinimumViableSystem checkWritableTempDir() {
checkWritableDir(System.getProperty("java.io.tmpdir"));
return this;
}
// Visible for testing
void checkWritableDir(String tempPath) {
try {
File tempFile = File.createTempFile("check", "tmp", new File(tempPath));
deleteQuietly(tempFile);
} catch (IOException e) {
throw new IllegalStateException(format("Temp directory is not writable: %s", tempPath), e);
}
}
public MinimumViableSystem checkRequiredJavaOptions(Map<String, String> requiredJavaOptions) {
for (Map.Entry<String, String> entry : requiredJavaOptions.entrySet()) {
String value = System.getProperty(entry.getKey());
if (!CS.equals(value, entry.getValue())) {
throw new MessageException(format(
"JVM option '%s' must be set to '%s'. Got '%s'", entry.getKey(), entry.getValue(), StringUtils.defaultString(value)));
}
}
return this;
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Ensure the temp directory exists and grant the JVM user write permission on it
- Set -Djava.io.tmpdir to a valid writable path
- Check disk free space
- Inspect the wrapped IOException cause for the precise OS error
Example fix
// before java -jar sonar.jar // after java -Djava.io.tmpdir=/var/tmp/sonar -jar sonar.jar # with /var/tmp/sonar writable
Defensive patterns
Strategy: validation
Validate before calling
File tmp = new File(System.getProperty("java.io.tmpdir"));
if (!tmp.isDirectory() || !tmp.canWrite()) {
throw new IllegalStateException("Temp dir missing or not writable: " + tmp);
} Try / catch
try { mvs.checkWritableTemp(); } catch (IllegalStateException e) { LOGGER.error("Fix java.io.tmpdir permissions", e); System.exit(1); } Prevention
- Ensure the OS temp dir exists and is writable by the service user
- Set -Djava.io.tmpdir explicitly in restricted environments
- Monitor disk free space
When it happens
Trigger: checkWritableTemp() (or checkWritableDir) run against a temp directory that is read-only, does not exist, or denies write permission to the JVM user.
Common situations: java.io.tmpdir points to a missing or read-only path; process runs under a restricted service account; disk full; sandboxed/containerized environment with limited permissions.
Understand the failure class
Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.
Related errors
- Can not delete
- Can not move file to
- Directory could not be created
- Can not open file
- Could not delete Elasticsearch temporary conf directory
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/42fa9a3b6fc3c489.
Report an issue: GitHub.