{"record":{"id":"9e4aa51e91c8d216","repo":"elastic/elasticsearch","slug":"failed-to-run-for","errorCode":null,"errorMessage":"Failed to run {} for {}","messagePattern":"Failed to run (.+?) for (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java","lineNumber":795,"sourceCode":"            );\n        }\n        try (InputStream byteArrayInputStream = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8))) {\n            LoggedExec.exec(execOperations, spec -> {\n                spec.setEnvironment(getESEnvironment());\n                spec.workingDir(getDistroDir());\n                spec.executable(OS.conditionalString().onUnix(() -> \"./bin/\" + tool).onWindows(() -> \"cmd\").supply());\n                spec.args(OS.<List<CharSequence>>conditional().onWindows(() -> {\n                    ArrayList<CharSequence> result = new ArrayList<>();\n                    result.add(\"/c\");\n                    result.add(\"bin\\\\\" + tool + \".bat\");\n                    Collections.addAll(result, args);\n                    return result;\n                }).onUnix(() -> Arrays.asList(args)).supply());\n                spec.setStandardInput(byteArrayInputStream);\n\n            });\n        } catch (IOException e) {\n            throw new UncheckedIOException(\"Failed to run \" + tool + \" for \" + this, e);\n        }\n    }\n\n    private void runKeystoreCommandWithPassword(String keystorePassword, String input, CharSequence... args) {\n        final String actualInput = keystorePassword.length() > 0 ? keystorePassword + \"\\n\" + input : input;\n        runElasticsearchBinScriptWithInput(actualInput, \"elasticsearch-keystore\", args);\n    }\n\n    private void runElasticsearchBinScript(String tool, CharSequence... args) {\n        runElasticsearchBinScriptWithInput(\"\", tool, args);\n    }\n\n    private Map<String, String> getESEnvironment() {\n        Map<String, String> defaultEnv = new HashMap<>();\n        // If we are testing the current version of Elasticsearch, use the configured runtime Java, otherwise use the bundled JDK\n        if (getTestDistribution() == TestDistribution.INTEG_TEST || getVersion().equals(VersionProperties.getElasticsearchVersion())) {\n            defaultEnv.put(\"ES_JAVA_HOME\", runtimeJava.get().getAbsolutePath());\n        }","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java#L777-L813","documentation":"Thrown by runElasticsearchBinScriptWithInput when LoggedExec.exec raises an IOException (the bin script was found, but the process could not be launched or the stream copy failed). The IOException is wrapped as UncheckedIOException with the tool name and node identity. This is a process-launch failure, not a non-zero exit code (LoggedExec handles exit codes separately).","triggerScenarios":"Process spawn fails: the executable path is unreadable (permissions), the input ByteArrayInputStream cannot be read, execOperations cannot fork (process limit), or the OS refused the spawn. Also when the stdio redirection setup raises IOException inside the exec spec.","commonSituations":"Permissions on bin/elasticsearch-keystore not executable. Too many open files / process limit on a CI agent. Transient OS error spawning the process. Broken pipe to a closed parent. Disk/FS error reading the distro bin script.","solutions":["Inspect the wrapped IOException cause for the precise spawn error.","On CI, raise ulimit -u / -n if process or fd limits are hit.","Verify bin/<tool> is executable on disk (chmod +x); clean and re-extract the distro if not.","Re-run; if transient, isolate which tool/path fails and capture stderr via esOutputFile."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the tool path is executable before relying on it\nPath tool = node.getDistroDir().resolve(\"bin\").resolve(toolName);\nif (Files.exists(tool) && !Files.isExecutable(tool)) {\n    throw new IllegalStateException(\"bin script not executable: \" + tool);\n}","typeGuard":null,"tryCatchPattern":"try {\n    node.start();\n} catch (UncheckedIOException e) {\n    if (e.getMessage().startsWith(\"Failed to run \")) {\n        // process spawn failure; check ulimits, perms, AV\n        throw new IllegalStateException(\"Bin script spawn failed: \" + e.getCause(), e);\n    }\n    throw e;\n}","preventionTips":["Raise ulimit -u / -n on CI agents.","Keep bin scripts executable in the distro; clean and re-extract if perms drift.","Capture esOutputFile to diagnose transient spawn failures."],"tags":["testclusters","process","io","bin-scripts"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}