{"record":{"id":"a882edf3ce1dce81","repo":"elastic/elasticsearch","slug":"74-a882ed","errorCode":"74","errorMessage":"bin dir for {pluginId} is not a directory","messagePattern":"bin dir for (.+?) is not a directory","errorType":"exception","errorClass":"UserException","httpStatus":null,"severity":"error","filePath":"distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/RemovePluginAction.java","lineNumber":153,"sourceCode":"\n            if (PLUGINS_CONVERTED_TO_MODULES.contains(pluginId)) {\n                terminal.errorPrintln(\n                    \"plugin [\" + pluginId + \"] is no longer a plugin but instead a module packaged with this distribution of Elasticsearch\"\n                );\n            } else {\n                final String message = String.format(\n                    Locale.ROOT,\n                    \"plugin [%s] not found; run 'elasticsearch-plugin list' to get list of installed plugins\",\n                    pluginId\n                );\n                throw new UserException(ExitCodes.CONFIG, message);\n            }\n        }\n\n        final Path pluginBinDir = env.binDir().resolve(pluginId);\n        if (Files.exists(pluginBinDir)) {\n            if (Files.isDirectory(pluginBinDir) == false) {\n                throw new UserException(ExitCodes.IO_ERROR, \"bin dir for \" + pluginId + \" is not a directory\");\n            }\n        }\n    }\n\n    private void removePlugin(InstallablePlugin plugin) throws IOException {\n        final String pluginId = plugin.getId();\n        final Path pluginDir = env.pluginsDir().resolve(pluginId);\n        final Path pluginConfigDir = env.configDir().resolve(pluginId);\n        final Path removing = env.pluginsDir().resolve(\".removing-\" + pluginId);\n\n        terminal.println(\"-> removing [\" + pluginId + \"]...\");\n\n        final List<Path> pluginPaths = new ArrayList<>();\n\n        /*\n         * Add the contents of the plugin directory before creating the marker file and adding it to the list of paths to be deleted so\n         * that the marker file is the last file to be deleted.\n         */","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/RemovePluginAction.java#L135-L171","documentation":"Thrown by RemovePluginAction.checkCanRemove when a plugin's bin directory exists at env.binDir().resolve(pluginId) but is not a directory (i.e. it is a regular file or special node). Exit code IO_ERROR (74). This guards removePlugin from trying to treat a non-directory path as a directory.","triggerScenarios":"After the not-found check, the code resolves pluginBinDir; if `Files.exists(pluginBinDir)` is true but `Files.isDirectory(pluginBinDir)` is false, it throws. Reached when something created a regular file at `<binDir>/<pluginId>` where a directory was expected.","commonSituations":"A stray file (log, tarball fragment, symlink to a file) was left at the plugin's bin path; manual cleanup that `touch`ed the path; filesystem corruption or a bad extraction leaving a file where the directory should be.","solutions":["Inspect `<ES_HOME>/bin/<pluginId>`: if it is a regular file, move/remove it so the path is either absent or a directory.","Reinstall the plugin cleanly to recreate the proper bin directory, then remove via the CLI.","Avoid manual file creation under the bin root; use the CLI for all install/remove operations."],"exampleFix":"# before: <ES_HOME>/bin/analysis-icu is a file\nls -ld <ES_HOME>/bin/analysis-icu\n# remove the stray file:\nrm <ES_HOME>/bin/analysis-icu\n# then retry:\nbin/elasticsearch-plugin remove analysis-icu","handlingStrategy":"validation","validationCode":"// Check the plugin bin path is a directory before removal.\nPath binDir = env.binDir().resolve(id);\nif (Files.exists(binDir) && !Files.isDirectory(binDir)) {\n    throw new IllegalStateException(binDir + \" is not a directory; investigate manually\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never create files manually under ES_HOME/bin; use the CLI only.","Audit bin/ for stray files after any manual plugin operation.","Reinstall the affected plugin cleanly if the bin path is corrupted."],"tags":["plugin-remove","filesystem","plugin-cli"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}