Fixing "duplicate plugin" issues in Elasticsearch

Fixing "duplicate plugin" issues in Elasticsearch

Sometimes, when installing or upgrading plugins within elasticsearch old installation files will remain after installation or removal. If these files are not cleaned up the installation or upgrade of new plugins will not be possible and you'll encounter the following error.

# /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch --verbose ingest-attachment
Checking if url exists: https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-linux-x86_64-6.5.4.zip
-> Downloading ingest-attachment from elastic
Retrieving zip from https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-6.5.4.zip
[=================================================] 100%   
- Plugin information:
Name: ingest-attachment
Description: Ingest processor that uses Apache Tika to extract contents
Version: 6.5.4
Elasticsearch Version: 6.5.4
Java Version: 1.8
Native Controller: false
Extended Plugins: []
 * Classname: org.elasticsearch.ingest.attachment.IngestAttachmentPlugin
Exception in thread "main" java.lang.IllegalStateException: duplicate plugin: - Plugin information:
Name: ingest-attachment
Description: Ingest processor that uses Apache Tika to extract contents
Version: 6.5.4
Elasticsearch Version: 6.5.4
Java Version: 1.8
Native Controller: false
Extended Plugins: []
 * Classname: org.elasticsearch.ingest.attachment.IngestAttachmentPlugin
        at org.elasticsearch.plugins.PluginsService.readPluginBundle(PluginsService.java:398)
        at org.elasticsearch.plugins.PluginsService.findBundles(PluginsService.java:379)
        at org.elasticsearch.plugins.PluginsService.getPluginBundles(PluginsService.java:372)
        at org.elasticsearch.plugins.InstallPluginCommand.jarHellCheck(InstallPluginCommand.java:755)
        at org.elasticsearch.plugins.InstallPluginCommand.loadPluginInfo(InstallPluginCommand.java:727)
        at org.elasticsearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:792)
        at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:775)
        at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:231)
        at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:216)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
        at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:77)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:47)
root@insight1:~# /usr/share/elasticsearch/bin/elasticsearch-plugin uninstall ingest-attachment
A tool for managing installed elasticsearch plugins

The worst part of this issue is the error specifically states there is a duplicate plugin and should you do a plugin list or run the removal command the duplicate plugin won't be found. However, the solution to this issue is simple though not 100% obvious; we just need to remove the old files. The old files will be in the plugin path which looks something like so: /usr/share/elasticsearch/plugins/.installing-XXXXXXXXXXXXXXXXXXX. The clean up is easily done using rm -rf technology, which has the power to remove all of the offending files. Once the files have been cleaned up, re-run the installation command.

# /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch --verbose ingest-attachment
Checking if url exists: https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-linux-x86_64-6.5.4.zip
-> Downloading ingest-attachment from elastic
Retrieving zip from https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-6.5.4.zip
[=================================================] 100%   
- Plugin information:
Name: ingest-attachment
Description: Ingest processor that uses Apache Tika to extract contents
Version: 6.5.4
Elasticsearch Version: 6.5.4
Java Version: 1.8
Native Controller: false
Extended Plugins: []
 * Classname: org.elasticsearch.ingest.attachment.IngestAttachmentPlugin
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessClassInPackage.sun.java2d.cmm.kcms
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.RuntimePermission getClassLoader
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.security.SecurityPermission createAccessControlContext
* java.security.SecurityPermission insertProvider
* java.security.SecurityPermission putProviderProperty.BC
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
-> Installed ingest-attachment

Happy Hacking

I hope this helps and if it does, let me know. Reach out on IRC or Twitter!

Mastodon