{"record":{"id":"42fa9a3b6fc3c489","repo":"SonarSource/sonarqube","slug":"temp-directory-is-not-writable-s","errorCode":null,"errorMessage":"Temp directory is not writable: %s","messagePattern":"Temp directory is not writable: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java","lineNumber":47,"sourceCode":"import static org.sonar.process.FileUtils2.deleteQuietly;\n\npublic class MinimumViableSystem {\n\n  /**\n   * Verify that temp directory is writable\n   */\n  public MinimumViableSystem checkWritableTempDir() {\n    checkWritableDir(System.getProperty(\"java.io.tmpdir\"));\n    return this;\n  }\n\n  // Visible for testing\n  void checkWritableDir(String tempPath) {\n    try {\n      File tempFile = File.createTempFile(\"check\", \"tmp\", new File(tempPath));\n      deleteQuietly(tempFile);\n    } catch (IOException e) {\n      throw new IllegalStateException(format(\"Temp directory is not writable: %s\", tempPath), e);\n    }\n  }\n\n  public MinimumViableSystem checkRequiredJavaOptions(Map<String, String> requiredJavaOptions) {\n    for (Map.Entry<String, String> entry : requiredJavaOptions.entrySet()) {\n      String value = System.getProperty(entry.getKey());\n      if (!CS.equals(value, entry.getValue())) {\n        throw new MessageException(format(\n          \"JVM option '%s' must be set to '%s'. Got '%s'\", entry.getKey(), entry.getValue(), StringUtils.defaultString(value)));\n      }\n    }\n    return this;\n  }\n}\n","sourceCodeStart":29,"sourceCodeEnd":62,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java#L29-L62","documentation":"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.","triggerScenarios":"checkWritableTemp() (or checkWritableDir) run against a temp directory that is read-only, does not exist, or denies write permission to the JVM user.","commonSituations":"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.","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"],"exampleFix":"// before\njava -jar sonar.jar\n// after\njava -Djava.io.tmpdir=/var/tmp/sonar -jar sonar.jar  # with /var/tmp/sonar writable","handlingStrategy":"validation","validationCode":"File tmp = new File(System.getProperty(\"java.io.tmpdir\"));\nif (!tmp.isDirectory() || !tmp.canWrite()) {\n  throw new IllegalStateException(\"Temp dir missing or not writable: \" + tmp);\n}","typeGuard":null,"tryCatchPattern":"try { mvs.checkWritableTemp(); } catch (IllegalStateException e) { LOGGER.error(\"Fix java.io.tmpdir permissions\", e); System.exit(1); }","preventionTips":["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"],"tags":["filesystem","permissions","temp-directory"],"backgroundTag":"file-write-permission-denied","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}