{"record":{"id":"63fd87e3b955f708","repo":"elastic/elasticsearch","slug":"plugins-directory-missing-pluginsdir","errorCode":null,"errorMessage":"Plugins directory missing: {pluginsDir}","messagePattern":"Plugins directory missing: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/ListPluginsCommand.java","lineNumber":44,"sourceCode":"import java.util.Collections;\nimport java.util.List;\nimport java.util.Objects;\n\nimport static org.elasticsearch.plugins.cli.SyncPluginsAction.ELASTICSEARCH_PLUGINS_YML_CACHE;\n\n/**\n * A command for the plugin cli to list plugins installed in elasticsearch.\n */\nclass ListPluginsCommand extends EnvironmentAwareCommand {\n\n    ListPluginsCommand() {\n        super(\"Lists installed elasticsearch plugins\");\n    }\n\n    @Override\n    public void execute(Terminal terminal, OptionSet options, Environment env, ProcessInfo processInfo) throws Exception {\n        if (Files.exists(env.pluginsDir()) == false) {\n            throw new IOException(\"Plugins directory missing: \" + env.pluginsDir());\n        }\n\n        terminal.println(Terminal.Verbosity.VERBOSE, \"Plugins directory: \" + env.pluginsDir());\n        final List<Path> plugins = new ArrayList<>();\n        try (DirectoryStream<Path> paths = Files.newDirectoryStream(env.pluginsDir())) {\n            for (Path path : paths) {\n                if (path.getFileName().toString().equals(ELASTICSEARCH_PLUGINS_YML_CACHE) == false) {\n                    plugins.add(path);\n                }\n            }\n        }\n        Collections.sort(plugins);\n        for (final Path plugin : plugins) {\n            printPlugin(env, terminal, plugin, \"\");\n        }\n    }\n\n    private static void printPlugin(Environment env, Terminal terminal, Path plugin, String prefix) throws IOException {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/ListPluginsCommand.java#L26-L62","documentation":"Thrown by ListPluginsCommand.execute (an IOException, not a UserException) when env.pluginsDir() does not exist on disk at the moment the `list` CLI command runs. The command refuses to enumerate a missing plugins directory rather than silently printing an empty list. No exit code is attached because it is a raw IOException surfaced by the CLI harness.","triggerScenarios":"Running `elasticsearch-plugin list` (or any code path calling ListPluginsCommand.execute) on a node whose ES_HOME/plugins (or configured path.plugins) has not been created — e.g. before first run, after a partial cleanup, or with a misconfigured ES_PATH_CONF / path.plugins.","commonSituations":"Fresh extraction where the distribution's plugins/ dir was deleted; pointing ES_PATH_CONF at a non-existent config root; container image that pruned the plugins directory; running the plugin CLI from the wrong working directory so path resolution lands on a missing dir.","solutions":["Verify the plugins directory path: check `path.plugins` in elasticsearch.yml and the default ES_HOME/plugins.","Recreate the directory if it was deleted: `mkdir -p <ES_HOME>/plugins`.","Run the CLI from the correct ES_HOME so env.pluginsDir() resolves to the real distribution plugins dir."],"exampleFix":"# before: ES_PATH_CONF points at /etc/elasticsearch but plugins/ is under /usr/share/elasticsearch\nexport ES_HOME=/usr/share/elasticsearch\n# after: invoke from the real install root\n$ES_HOME/bin/elasticsearch-plugin list","handlingStrategy":"validation","validationCode":"// Before listing, confirm the plugins dir is present.\nPath plugins = env.pluginsDir();\nif (!Files.exists(plugins)) {\n    throw new FileNotFoundException(\"Plugins dir missing: \" + plugins);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set ES_HOME (and ES_PATH_CONF) explicitly before running the CLI.","In Docker images, do not prune the distribution's plugins/ directory.","Add a startup check that recreates an empty plugins/ dir if missing."],"tags":["plugin-cli","filesystem","environment","list"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}