SonarSource/sonarqube · error

Cannot write temporary settings to

Error message

Cannot write temporary settings to 

What it means

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.

Source

Thrown at server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java:300

    return Arrays.asList("-cp", String.join(pathSeparator, javaCommand.getClasspath()));
  }

  private File buildPropertiesFile(JavaCommand javaCommand) {
    File propertiesFile = null;
    try {
      propertiesFile = File.createTempFile("sq-process", "properties", tempDir);
      Properties props = new Properties();
      props.putAll(javaCommand.getArguments());
      props.setProperty(PROPERTY_PROCESS_KEY, javaCommand.getProcessId().getKey());
      props.setProperty(PROPERTY_PROCESS_INDEX, Integer.toString(javaCommand.getProcessId().getIpcIndex()));
      props.setProperty(PROPERTY_GRACEFUL_STOP_TIMEOUT_MS, javaCommand.getGracefulStopTimeoutMs() + "");
      props.setProperty(PROPERTY_SHARED_PATH, tempDir.getAbsolutePath());
      try (OutputStream out = new FileOutputStream(propertiesFile)) {
        props.store(out, format("Temporary properties file for command [%s]", javaCommand.getProcessId().getKey()));
      }
      return propertiesFile;
    } catch (Exception e) {
      throw new IllegalStateException("Cannot write temporary settings to " + propertiesFile, e);
    }
  }

  /**
   * An interface of the methods of {@link java.lang.ProcessBuilder} that we use in {@link ProcessLauncherImpl}.
   * <p>Allows testing creating processes without actualling creating them at OS level</p>
   */
  public interface ProcessBuilder {
    List<String> command();

    ProcessBuilder command(List<String> commands);

    ProcessBuilder directory(File dir);

    Map<String, String> environment();

    ProcessBuilder redirectErrorStream(boolean b);

View on GitHub (pinned to 184c821202)

Solutions

  1. Verify the process user can create and write files in the java.io.tmpdir (or SONAR temp dir) and that the directory exists
  2. Check free disk space on the partition holding the temp directory
  3. Disable or reconfigure temp-file cleaners (tmpwatch, systemd-tmpfiles) that delete sonar temp dirs while the server runs
  4. Inspect the wrapped cause (e.getCause()) to identify the exact IOException and fix the underlying filesystem issue

Example fix

// before (unwritable tmpdir)
java -Djava.io.tmpdir=/nowrite/sonartmp -jar sonar-application.jar
// after
mkdir -p /var/sonar/tmp && chown sonarqube:sonarqube /var/sonar/tmp
java -Djava.io.tmpdir=/var/sonar/tmp -jar sonar-application.jar
Defensive patterns

Strategy: try-catch

Validate before calling

File tmpDir = new File(System.getProperty("java.io.tmpdir"));
if (!tmpDir.canWrite() || tmpDir.getFreeSpace() < 10 * 1024 * 1024) {
  throw new IllegalStateException("temp dir not writable or low on disk: " + tmpDir);
}

Type guard

boolean isWritableDir(File d) {
  return d != null && d.isDirectory() && d.canWrite();
}

Try / catch

try {
  processLauncher.create(...);
} catch (IllegalStateException e) {
  if (e.getMessage().startsWith("Cannot write temporary settings")) {
    log.error("Check java.io.tmpdir permissions/disk space", e.getCause());
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/0217f6fa1b4aef14. Report an issue: GitHub.