elastic/elasticsearch · error · RuntimeException

Failed to create marker file

Error message

Failed to create marker file

What it means

Thrown by SplitPackagesAuditTask when writing the success marker file (Files.write on parameters.getMarkerFile()) raises an IOException. The split-package audit itself passed, but the task could not record that fact — without the marker the task re-runs every build, so it is treated as a hard failure.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java:197

                            .details(fullMessage)
                            .solution("Choose a new package name for the classes added. DO NOT add these to the ignore list.")
                    )
                );
            }
            if (splitPackages.isEmpty() == false) {
                throw reporter.throwing(
                    new GradleException(
                        "Verification failed: Split packages found! See errors above for details.\n"
                            + "DO NOT ADD THESE SPLIT PACKAGES TO THE IGNORE LIST! Choose a new package name for the classes added."
                    ),
                    problems
                );
            }

            try {
                Files.write(parameters.getMarkerFile().getAsFile().get().toPath(), new byte[] {}, StandardOpenOption.CREATE);
            } catch (IOException e) {
                throw new RuntimeException("Failed to create marker file", e);
            }
        }

        private Map<String, List<File>> getDependencyPackages() {
            Map<String, List<File>> packages = new HashMap<>();
            for (File classpathElement : getParameters().getClasspath().getFiles()) {
                for (String packageName : readPackages(classpathElement)) {
                    packages.computeIfAbsent(packageName, k -> new ArrayList<>()).add(classpathElement);
                }
            }
            if (LOGGER.isInfoEnabled()) {
                List<String> msg = new ArrayList<>();
                msg.add("Packages from dependencies:");
                packages.entrySet()
                    .stream()
                    .sorted(Map.Entry.comparingByKey())
                    .forEach(e -> msg.add("  -" + e.getKey() + " -> " + e.getValue()));
                LOGGER.info(String.join(System.lineSeparator(), msg));

View on GitHub (pinned to db6a809a66)

Solutions

  1. Inspect the wrapped IOException for the exact path and OS error.
  2. Ensure the marker file's parent directory is created and writable (the task should be configured with a build-dir-relative output).
  3. Run a clean build so the output tree is regenerated consistently.
  4. On Windows, close any process locking the build directory.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure marker parent exists before the task runs
File marker = parameters.getMarkerFile().getAsFile().get();
marker.getParentFile().mkdirs();
if (!marker.getParentFile().canWrite()) throw new GradleException("Marker dir not writable: " + marker.getParentFile());

Try / catch

try {
    Files.write(marker.toPath(), new byte[] {}, StandardOpenOption.CREATE);
} catch (IOException e) {
    // retry once after mkdirs, then escalate
    marker.getParentFile().mkdirs();
    Files.write(marker.toPath(), new byte[] {}, StandardOpenOption.CREATE);
}

Prevention

When it happens

Trigger: The marker file's parent directory does not exist or is not writable, or a generic I/O error occurs while creating the (empty) marker file.

Common situations: The build output directory was cleaned/deleted out-of-band; the marker path points to a read-only location; disk full or permission denied in the build dir; an antivirus/locker holding the file on Windows.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/24c6344387ca423a. Report an issue: GitHub.