如何将本地gem依赖项添加到自定义Logstash插件?

时间:2016-07-12 15:25:55

标签: logstash

我有一个ruby gem文件,它是实际的Logstash插件,我有另一个gemstark插件gem需要的gem。如何在我的Logstash中获取gem,以便我

require "gem_name"

它没有说“找不到gem_name”?

2 个答案:

答案 0 :(得分:0)

与往常一样,将您的本地gem作为插件中的依赖项包含在内。 然后,在安装插件之前,在Logstash中安装本地依赖项,如下所示:

/path/to/logstash/logstash-plugin install --no-verify /path/to/local/gem

然后安装你的插件

/path/to/logstash/logstash-plugin install /path/to/local/plugin

答案 1 :(得分:-1)

在您的 gemspec (在名为 plugin-name.gemspec 的插件文件夹中)添加具有依赖关系的行。例如。如果您的插件需要rest-client:

s.add_runtime_dependency "rest-client", '>= 1.8.0'

您可以找到具有依赖关系here的有效gemspec文件的示例。在rubygems.org上查看您选择的插件,以查找有效的版本声明。

一旦声明了所有依赖项运行bundle install,请使用gem build your-plugin-name.gemspec构建您的gem。然后安装并测试它:bin/logstash-plugin install logstash-filter-mypluginname.gem

我强烈建议RVM避免ruby版本问题。您可能还想考虑坚持使this tutorial更容易。如果您需要进一步的帮助,请与我们联系。