elastic/elasticsearch · error · RuntimeException
Failed to write marker file
Error message
Failed to write marker file
What it means
Thrown by DockerBuildAction.execute() when writing the computed image checksum to the task's marker file fails with an IOException. After building the image (and optionally pulling it for multi-platform builds), the task computes a checksum and writes `<checksum>\n` to the marker file so Gradle can do up-to-date checks; an IOException here is wrapped in a RuntimeException. The marker file is the task's declared output, so failing to write it fails the whole task.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerBuildTask.java:323
// (23.0+) that may create manifest lists even for single-platform builds
// when BuildKit is enabled.
spec.args("--load");
}
}
});
// Fetch the Docker image's hash, and write it to desk as the task's output. Doing this allows us
// to do proper up-to-date checks in Gradle.
try {
// multi-platform image builds do not end up in local registry, so we need to pull the just build image
// first to get the checksum and also serves as a test for the image being pushed correctly
if (parameters.getPlatforms().get().size() > 1 && parameters.getPush().getOrElse(false)) {
pullBaseImage(tags.get(0));
}
final String checksum = getImageChecksum(tags.get(0));
Files.writeString(parameters.getMarkerFile().getAsFile().get().toPath(), checksum + "\n");
} catch (IOException e) {
throw new RuntimeException("Failed to write marker file", e);
}
}
/**
* Resolves an {@code oci-layout://} build context value to a digest-qualified reference.
* Buildx resolves OCI layout contexts by tag or digest within the layout; the tag recorded
* in the layout's index is not always what buildx looks up by default, so pinning the
* manifest digest from {@code index.json} is the most robust way to reference the
* (single-image) layouts we export.
*/
private static String resolveBuildContext(String value) {
String prefix = "oci-layout://";
if (value.startsWith(prefix) == false || value.contains("@")) {
return value;
}
Path indexJson = Path.of(value.substring(prefix.length()), "index.json");
try {
// The exported layouts contain a single manifest, so plucking the first digest isView on GitHub (pinned to db6a809a66)
Solutions
- Check the marker file's parent directory exists and is writable by the build user.
- Ensure no concurrent build or `clean` is removing the output dir mid-task.
- Free disk space / verify the filesystem is writable.
- If the markerFile property was overridden in build config, point it at a valid writable path inside the project build dir.
Defensive patterns
Strategy: validation
Validate before calling
// Before building, assert the marker file's parent exists and is writable:
// Path parent = markerFile.toPath().getParent();
// if (!Files.isDirectory(parent) || !Files.isWritable(parent)) fail("bad marker dir"); Try / catch
// try { Files.writeString(markerPath, checksum + "\n"); }
// catch (IOException e) { throw new RuntimeException("Failed to write marker file", e); } Prevention
- Don't run `clean` concurrently with the Docker build task.
- Keep the marker file path inside the project build dir on a writable filesystem.
- Ensure adequate free disk space on CI workers.
When it happens
Trigger: Files.writeString(markerFile, checksum) throws IOException. Causes: the marker file's parent directory does not exist or is not writable; the output path was deleted mid-build; disk full or filesystem read-only; the path points to an invalid location; security manager / permissions deny the write.
Common situations: A `clean` or concurrent build removed the build output directory between task start and the write; the task's markerFile property is misconfigured to point at a read-only or non-existent parent; running on a CI ephemeral worker with a full tmpfs; permissions issue from running as a different user than the build dir owner.
Related errors
- Failed to read OCI image layout index [{indexJson}]
- Failed to read /etc/os-release
- Failed to read {exclusionsFileAbsolutePath}
- Failed to delete some files: {files}
- Unable to create reaper JAR output directory {}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/fe496d6b0a172a36.
Report an issue: GitHub.