{"record":{"id":"3abc67b85cbf768f","repo":"elastic/elasticsearch","slug":"can-t-run-bin-script-does-not-exist-is-this","errorCode":null,"errorMessage":"Can't run bin script: `{}` does not exist. Is this the distribution you expect it to be ?","messagePattern":"Can't run bin script: `(.+?)` does not exist\\. Is this the distribution you expect it to be \\?","errorType":"validation","errorClass":"TestClustersException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java","lineNumber":775,"sourceCode":"    @Override\n    public void rolesFile(File rolesYml) {\n        roleFiles.add(rolesYml);\n    }\n\n    @Override\n    public void requiresFeature(String feature, Version from) {\n        featureFlags.add(new FeatureFlag(feature, from, null));\n    }\n\n    @Override\n    public void requiresFeature(String feature, Version from, Version until) {\n        featureFlags.add(new FeatureFlag(feature, from, until));\n    }\n\n    private void runElasticsearchBinScriptWithInput(String input, String tool, CharSequence... args) {\n        if (Files.exists(getDistroDir().resolve(\"bin\").resolve(tool)) == false\n            && Files.exists(getDistroDir().resolve(\"bin\").resolve(tool + \".bat\")) == false) {\n            throw new TestClustersException(\n                \"Can't run bin script: `\" + tool + \"` does not exist. \" + \"Is this the distribution you expect it to be ?\"\n            );\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            });","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java#L757-L793","documentation":"Thrown by runElasticsearchBinScriptWithInput before exec when neither <distro>/bin/<tool> nor <distro>/bin/<tool>.bat exists. The node refuses to invoke a bin script that is not part of the unpacked distribution. The message prompts the developer to question the distribution choice because the most common root cause is selecting a distribution variant that does not ship the requested tool.","triggerScenarios":"Invoking (directly or via start()) a tool like 'elasticsearch-keystore', 'elasticsearch-plugin', or 'elasticsearch-users' on a distribution that does not contain it. Happens with the 'bare' minimal distribution (no x-pack), old versions that named scripts differently (e.g. 'x-pack/users' pre-6.3 vs 'elasticsearch-users' post-6.3), or a custom/ corrupt distro missing bin/.","commonSituations":"Using a distribution type that omits x-pack while the test calls elasticsearch-users. BWC test running against a version that uses the old script name. Plugin installed on a distribution where elasticsearch-plugin was renamed. Distribution partially extracted and bin/ missing.","solutions":["Switch to a distribution variant that ships the tool (e.g. the default/x-pack distribution rather than 'bare' when you need elasticsearch-users).","For BWC across 6.3.0, the code already picks the right tool name; if you bypass it, mirror that logic.","Verify <distro>/bin/ on disk (ls build/testclusters/<node>/<distro>/bin/) and clean/re-extract if bin/ is missing.","Confirm the version string matches a real ES release; a malformed version can select a wrong distro."],"exampleFix":"// before: bare distro lacks elasticsearch-users\ntestClusters {\n  n { distribution 'bare', '8.15.0'; user([:]) }\n}\n// after: default distro ships x-pack tooling\ntestClusters {\n  n { distribution 'default', '8.15.0'; user([:]) }\n}","handlingStrategy":"validation","validationCode":"static void ensureBinToolExists(Path distroDir, String tool) {\n    boolean ok = Files.exists(distroDir.resolve(\"bin\").resolve(tool))\n             || Files.exists(distroDir.resolve(\"bin\").resolve(tool + \".bat\"));\n    if (!ok) {\n        throw new IllegalStateException(\"Distribution \" + distroDir\n            + \" does not provide bin/\" + tool + \"; pick a distribution variant that ships it.\");\n    }\n}\n// Use: ensureBinToolExists(node.getDistroDir(), \"elasticsearch-users\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the default/x-pack distribution when you need elasticsearch-users or elasticsearch-keystore.","For BWC across 6.3.0, rely on the built-in tool-name selection.","Verify bin/ contents after extraction."],"tags":["testclusters","distribution","bin-scripts","versioning","startup"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}