{"record":{"id":"0217f6fa1b4aef14","repo":"SonarSource/sonarqube","slug":"cannot-write-temporary-settings-to","errorCode":null,"errorMessage":"Cannot write temporary settings to ","messagePattern":"Cannot write temporary settings to ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java","lineNumber":300,"sourceCode":"    return Arrays.asList(\"-cp\", String.join(pathSeparator, javaCommand.getClasspath()));\n  }\n\n  private File buildPropertiesFile(JavaCommand javaCommand) {\n    File propertiesFile = null;\n    try {\n      propertiesFile = File.createTempFile(\"sq-process\", \"properties\", tempDir);\n      Properties props = new Properties();\n      props.putAll(javaCommand.getArguments());\n      props.setProperty(PROPERTY_PROCESS_KEY, javaCommand.getProcessId().getKey());\n      props.setProperty(PROPERTY_PROCESS_INDEX, Integer.toString(javaCommand.getProcessId().getIpcIndex()));\n      props.setProperty(PROPERTY_GRACEFUL_STOP_TIMEOUT_MS, javaCommand.getGracefulStopTimeoutMs() + \"\");\n      props.setProperty(PROPERTY_SHARED_PATH, tempDir.getAbsolutePath());\n      try (OutputStream out = new FileOutputStream(propertiesFile)) {\n        props.store(out, format(\"Temporary properties file for command [%s]\", javaCommand.getProcessId().getKey()));\n      }\n      return propertiesFile;\n    } catch (Exception e) {\n      throw new IllegalStateException(\"Cannot write temporary settings to \" + propertiesFile, e);\n    }\n  }\n\n  /**\n   * An interface of the methods of {@link java.lang.ProcessBuilder} that we use in {@link ProcessLauncherImpl}.\n   * <p>Allows testing creating processes without actualling creating them at OS level</p>\n   */\n  public interface ProcessBuilder {\n    List<String> command();\n\n    ProcessBuilder command(List<String> commands);\n\n    ProcessBuilder directory(File dir);\n\n    Map<String, String> environment();\n\n    ProcessBuilder redirectErrorStream(boolean b);\n","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java#L282-L318","documentation":"ProcessLauncherImpl.buildPropertiesFile serializes the child-process properties to a temporary file so a spawned SonarQube process (Compute Engine, Elasticsearch, web) can read its settings. If any step of creating or storing that file throws (missing directory, no permissions, disk full), it is rethrown as IllegalStateException with the target path appended to the message.","triggerScenarios":"Calling create() on ProcessLauncherImpl to launch a managed child process when FileOutputStream(propertiesFile) fails: the temp directory was deleted between creation and write, the filesystem is read-only or full, or permissions deny writing to java.io.tmpdir.","commonSituations":"Security-hardened /tmp with noexec or restrictive permissions, a tmpwatch/systemd-tmpfiles cleaner removing the temp dir mid-run, disk-full conditions on servers, or running the SonarQube server as a user without write access to the temp directory.","solutions":["Verify the process user can create and write files in the java.io.tmpdir (or SONAR temp dir) and that the directory exists","Check free disk space on the partition holding the temp directory","Disable or reconfigure temp-file cleaners (tmpwatch, systemd-tmpfiles) that delete sonar temp dirs while the server runs","Inspect the wrapped cause (e.getCause()) to identify the exact IOException and fix the underlying filesystem issue"],"exampleFix":"// before (unwritable tmpdir)\njava -Djava.io.tmpdir=/nowrite/sonartmp -jar sonar-application.jar\n// after\nmkdir -p /var/sonar/tmp && chown sonarqube:sonarqube /var/sonar/tmp\njava -Djava.io.tmpdir=/var/sonar/tmp -jar sonar-application.jar","handlingStrategy":"try-catch","validationCode":"File tmpDir = new File(System.getProperty(\"java.io.tmpdir\"));\nif (!tmpDir.canWrite() || tmpDir.getFreeSpace() < 10 * 1024 * 1024) {\n  throw new IllegalStateException(\"temp dir not writable or low on disk: \" + tmpDir);\n}","typeGuard":"boolean isWritableDir(File d) {\n  return d != null && d.isDirectory() && d.canWrite();\n}","tryCatchPattern":"try {\n  processLauncher.create(...);\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"Cannot write temporary settings\")) {\n    log.error(\"Check java.io.tmpdir permissions/disk space\", e.getCause());\n  }\n  throw e;\n}","preventionTips":["Point java.io.tmpdir at a dedicated dir owned by the service user","Monitor free disk space on the temp partition","Exclude sonar temp dirs from tmpwatch/systemd-tmpfiles cleanup","Run the server under a non-restricted account with write access to tmp"],"tags":["java","filesystem","process-launch"],"backgroundTag":"file-write-failed","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"}