{"record":{"id":"e4d166a3a7ea59f9","repo":"elastic/elasticsearch","slug":"failed-to-create-working-directory-for-with","errorCode":null,"errorMessage":"Failed to create working directory for {}, with: {}","messagePattern":"Failed to create working directory for (.+?), with: (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java","lineNumber":498,"sourceCode":"                logToProcessStdout(\"Configuring working directory: \" + workingDir);\n                // make sure we always start fresh\n                if (Files.exists(workingDir)) {\n                    if (preserveDataDir) {\n                        try (var files = Files.list(workingDir)) {\n                            files.filter(path -> path.equals(confPathData) == false).forEach(this::uncheckedDeleteWithRetry);\n                        }\n                    } else {\n                        deleteWithRetry(workingDir);\n                    }\n                }\n                isWorkingDirConfigured = true;\n            }\n            setupNodeDistribution(getExtractedDistributionDir());\n            createWorkingDir();\n        } catch (IOException e) {\n            String msg = \"Failed to create working directory for \" + this + \", with: \" + e + throwableToString(e);\n            logToProcessStdout(msg);\n            throw new UncheckedIOException(msg, e);\n        } catch (org.gradle.api.UncheckedIOException e) {\n            String msg = \"Failed to create working directory for \" + this + \", with: \" + e + throwableToString(e);\n            logToProcessStdout(msg);\n            throw e;\n        }\n\n        copyExtraJars();\n\n        copyExtraConfigFiles();\n\n        createConfiguration();\n\n        if (plugins.isEmpty() == false) {\n            if (getVersion().onOrAfter(\"7.6.0\")) {\n                logToProcessStdout(\"installing \" + plugins.size() + \" plugins in a single transaction\");\n                final String[] arguments = Stream.concat(\n                    Stream.of(\"install\", \"--batch\"),\n                    plugins.stream().map(Provider::get).map(p -> p.toURI().toString())","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java#L480-L516","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before start(), confirm the working dir parent is writable and path is reasonable\nPath parent = node.getWorkingDir().getParent();\nif (!Files.isWritable(parent)) {\n    throw new IllegalStateException(\"Cannot create working dir under \" + parent + \" (not writable)\");\n}\nif (OS.current() == OS.WINDOWS && node.getWorkingDir().toString().length() > 240) {\n    throw new IllegalStateException(\"Working dir path too long for Windows MAX_PATH: \" + node.getWorkingDir());\n}","typeGuard":null,"tryCatchPattern":"// At the test/task level, wrap start() and report FS cause cleanly\ntry {\n    node.start();\n} catch (UncheckedIOException e) {\n    throw new IllegalStateException(\"Node working dir setup failed (disk/perms/path-length): \"\n        + e.getMessage(), e);\n}","preventionTips":["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."],"tags":["testclusters","filesystem","io","startup","disk-full"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}