{"record":{"id":"114b0294dc024888","repo":"SonarSource/sonarqube","slug":"failed-to-create-temporary-configuration-directory","errorCode":null,"errorMessage":"Failed to create temporary configuration directory [%s]","messagePattern":"Failed to create temporary configuration directory \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java","lineNumber":166,"sourceCode":"    esInstallation.getEsJvmOptions().writeToJvmOptionFile(esInstallation.getJvmOptions());\n    storeElasticsearchLog4j2Properties(esInstallation);\n  }\n\n  private static void pruneElasticsearchConfDirectory(File confDir) {\n    try {\n      if (confDir.exists()) {\n        FileUtils2.deleteDirectory(confDir);\n      }\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Could not delete Elasticsearch temporary conf directory\", e);\n    }\n  }\n\n  private static void createElasticsearchConfDirectory(File confDir) {\n    if (!confDir.mkdirs()) {\n      String error = format(\"Failed to create temporary configuration directory [%s]\", confDir.getAbsolutePath());\n      LOG.error(error);\n      throw new IllegalStateException(error);\n    }\n  }\n\n  private void setupElasticsearchSecurity(EsInstallation esInstallation) {\n    if (esInstallation.isSecurityEnabled()) {\n      EsKeyStoreCli keyStoreCli = EsKeyStoreCli.getInstance(esInstallation);\n\n      setupElasticsearchAuthentication(esInstallation, keyStoreCli);\n      setupElasticsearchHttpEncryption(esInstallation, keyStoreCli);\n\n      keyStoreCli.executeWith(this::launchJava);\n    }\n  }\n\n  private static void setupElasticsearchAuthentication(EsInstallation esInstallation, EsKeyStoreCli keyStoreCli) {\n    keyStoreCli.store(BOOTSTRAP_PASSWORD_PROPERTY_KEY, esInstallation.getBootstrapPassword());\n\n    String esConfPath = esInstallation.getConfDirectory().getAbsolutePath();","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java#L148-L184","documentation":"createElasticsearchConfDirectory creates the temporary ES conf directory with mkdirs(). If mkdirs() returns false (directory cannot be created — it already exists as a file, or parent is not writable), it logs and throws this IllegalStateException, aborting process launch because ES cannot start without a conf directory.","triggerScenarios":"writeConfFiles() -> createElasticsearchConfDirectory() where File.mkdirs() fails on the ES temp conf path: parent directory missing/unwritable, a file exists at the target path, or out of inodes/space.","commonSituations":"Read-only container filesystems; incorrect ownership of sonar.path.temp; a stale file where the conf directory should be; SELinux/AppArmor blocking directory creation.","solutions":["Verify and fix write permissions/ownership on sonar.path.temp (chown -R sonarqube:sonarqube).","Remove any non-directory file existing at the conf path and clear the temp directory while stopped.","Check disk space and inode availability on the temp filesystem.","Check SELinux/AppAudit policies if creation is still denied on a writable path."],"exampleFix":"$ sudo systemctl stop sonarqube\n$ ls -la /opt/sonarqube/temp\n$ sudo chown -R sonarqube:sonarqube /opt/sonarqube/temp\n$ sudo systemctl start sonarqube","handlingStrategy":"validation","validationCode":"File conf = new File(tempDir, \"conf\");\nFile parent = conf.getParentFile();\nif (parent == null || !parent.canWrite() || (conf.exists() && !conf.isDirectory())) {\n    throw new IllegalStateException(\"Cannot create ES conf dir under: \" + parent);\n}","typeGuard":null,"tryCatchPattern":"try { launcher.launch(...); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Failed to create temporary configuration\")) { fixPermissionsAndRetry(); } }","preventionTips":["Ensure sonar.path.temp exists, is writable, and owned by the service user.","Use writable persistent storage in containers for the temp path.","Monitor free inodes/disk space on the temp volume."],"tags":["filesystem","mkdir","elasticsearch"],"backgroundTag":"mkdir-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"}