elastic/elasticsearch · error · UncheckedIOException
Failed to create working directory for {}, with: {}
Error message
Failed to create working directory for {}, with: {} What it means
Thrown when createWorkingDir() (called from start()) raises an IOException, which the code wraps in an UncheckedIOException with the full stack trace appended via throwableToString. The node could not create its working directory under build/testclusters. A parallel catch re-throws Gradle's own UncheckedIOException with the same diagnostic message.
Source
Thrown at build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java:498
logToProcessStdout("Configuring working directory: " + workingDir);
// make sure we always start fresh
if (Files.exists(workingDir)) {
if (preserveDataDir) {
try (var files = Files.list(workingDir)) {
files.filter(path -> path.equals(confPathData) == false).forEach(this::uncheckedDeleteWithRetry);
}
} else {
deleteWithRetry(workingDir);
}
}
isWorkingDirConfigured = true;
}
setupNodeDistribution(getExtractedDistributionDir());
createWorkingDir();
} catch (IOException e) {
String msg = "Failed to create working directory for " + this + ", with: " + e + throwableToString(e);
logToProcessStdout(msg);
throw new UncheckedIOException(msg, e);
} catch (org.gradle.api.UncheckedIOException e) {
String msg = "Failed to create working directory for " + this + ", with: " + e + throwableToString(e);
logToProcessStdout(msg);
throw e;
}
copyExtraJars();
copyExtraConfigFiles();
createConfiguration();
if (plugins.isEmpty() == false) {
if (getVersion().onOrAfter("7.6.0")) {
logToProcessStdout("installing " + plugins.size() + " plugins in a single transaction");
final String[] arguments = Stream.concat(
Stream.of("install", "--batch"),
plugins.stream().map(Provider::get).map(p -> p.toURI().toString())View on GitHub (pinned to db6a809a66)
Solutions
- Free disk space and check inodes (df -h, df -i) on the build host; clear Gradle caches if full.
- Shorten the project path / move the build closer to the filesystem root on Windows to avoid MAX_PATH.
- Fix ownership/permissions on build/testclusters so the current user can create directories (chown -R).
- Read the appended stack trace in the message to find the exact failing FS call (createWorkingDir vs setupNodeDistribution) and address that specific path.
Defensive patterns
Strategy: try-catch
Validate before calling
// Before start(), confirm the working dir parent is writable and path is reasonable
Path parent = node.getWorkingDir().getParent();
if (!Files.isWritable(parent)) {
throw new IllegalStateException("Cannot create working dir under " + parent + " (not writable)");
}
if (OS.current() == OS.WINDOWS && node.getWorkingDir().toString().length() > 240) {
throw new IllegalStateException("Working dir path too long for Windows MAX_PATH: " + node.getWorkingDir());
} Try / catch
// At the test/task level, wrap start() and report FS cause cleanly
try {
node.start();
} catch (UncheckedIOException e) {
throw new IllegalStateException("Node working dir setup failed (disk/perms/path-length): "
+ e.getMessage(), e);
} Prevention
- Keep testclusters build paths short, especially on Windows.
- Run Gradle as the same user that owns build/ to avoid permission residue.
- Monitor disk/inode usage on shared CI agents.
When it happens
Trigger: Calling start() when the working directory path is not creatable: read-only parent, exhausted inode/disk quota, path exceeding filesystem limits (notably MAX_PATH on Windows CI), or a pre-existing file occupying the directory name. Also when setupNodeDistribution (which can symlink/copy) fails with an I/O error in the same try block.
Common situations: Long build paths on Windows exceeding 260 chars. Disk full on a CI agent. Permission clash after running Gradle as root then as a normal user. Antivirus locking files on Windows. NFS/build-server filesystem hiccups.
Related errors
- Failed to write unicast_hosts for {}
- Can not start {}, is not a directory: {}
- Can't create extra config file for
- Can't copy extra jar dependency {} to {}
- Can't append roles file {} to {}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/e4d166a3a7ea59f9.
Report an issue: GitHub.