Elasticsearch output plugin fails with "undefined method `version' for nil:NilClass"


(Sven Beauprez) #1

I want to work and extend functionality of the elasticsearch plugin, but I have an issue running the original plugin.

After succesfully building the gem file for the master branch of logstash-output-elasticsearch (output 17,8MB file 'logstash-output-elasticsearch-1.0.7.gem') and successfully installing the plugin in logstash 1.5.2), I am getting following error when starting logstash (using --debug flag):

...
Plugin not defined in namespace, checking for plugin file {:type=>"output", :name=>"elasticsearch", :path=>"logstash/outputs/elasticsearch", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
[2015-08-14 15:12:46.085]  WARN -- Concurrent: [DEPRECATED] Java 7 is deprecated, please use Java 8.
Java 7 support is only best effort, it may not work. It will be removed in next release (1.0).
The error reported is: 
  undefined method 'version' for nil:NilClass
/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/util/plugin_version.rb:26:in 'find_version!'
/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/util/plugin_version.rb:36:in `find_plugin_version!'

When looking at the code of plugin_version.rb, it seems it should be able to simple lookup the version within the filename. Correct? (not a lot of ruby experience, so it is an assumption I am making here)

def self.find_version!(name)
  begin
    specification = Gem::Specification.find_by_name(name)
    new(specification.version)
  rescue Gem::LoadError
    # Rescuing the LoadError and raise a Logstash specific error.
    # Likely we can't find the gem in the current GEM_PATH
    raise LogStash::PluginNoVersionError
  end
end

What could have gone wrong when installing/using my build version of the plugin?


(system) #2