elasticsearch/logstash — pull request #1868 by haoch (2014-10-10 02:24:48+00:00)
Title: Bug in Logstash Package Building

Problem
-----------
I am trying to build my own RPM package using `make package`, but when I installs with the generated package into another clean system, logstash failed with following errors

~~~bash
haochen@machine /opt/logstash$ ./bin/logstash
LoadError: no such file to load -- /opt/logstash/vendor/bundle/bundler/setup
require at org/jruby/RubyKernel.java:1065
require at /opt/logstash/vendor/jar/jruby-complete-1.7.16.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
set_gem_paths! at /opt/logstash/lib/logstash/environment.rb:41
(root) at /opt/logstash/lib/logstash/runner.rb:8
~~~

Reason
----------
The error is caused by @colinsurprenant 's commit here:
https://github.com/elasticsearch/logstash/commit/b6c8e96480898aad31ad2d6d7e3ec20425f6e91a#diff-877661150c0eb1603494932696435bb0R41 where it starts to require `#{BUNDLE_DIR}/bundler/setup.rb`
~~~ruby
def set_gem_paths!
require ::File.join(BUNDLE_DIR, "bundler", "setup.rb")
ENV["GEM_PATH"] = plugins_home
ENV["GEM_HOME"] = plugins_home
end
~~~

**BUT** problem is that Makefile specification of `make package` https://github.com/elasticsearch/logstash/blob/master/Makefile#L383

~~~bash
$(QUIET)rsync -a --relative bin lib spec locales patterns vendor/bundle/jruby vendor/geoip vendor/jar vendor/kibana vendor/ua-parser vendor/collectd LICENSE README.md --exclude 'vendor/bundle/jruby/1.9/cache' --exclude 'vendor/bundle/jruby/1.9/gems/*/doc' --exclude 'vendor/jar/elasticsearch-$(ELASTICSEARCH_VERSION).tar.gz' --exclude 'vendor/jar/kafka_$(SCALA_VERSION)-$(KAFKA_VERSION).tgz' $(WORKDIR)
~~~
It doesn't copy the required `vendor/bundle/bundler` into tarball package, so that when we install with the generated package, it will fail with errors as above for missing required files.

Solution
----------
The solution is very simple:　just add `vendor/bundle/bundler` into the rsync directories here (https://github.com/elasticsearch/logstash/blob/master/Makefile#L383) when preparing tarball:
~~~bash
$(QUIET)rsync -a --relative bin lib spec locales patterns vendor/bundle/bundler vendor/bundle/jruby vendor/geoip vendor/jar vendor/kibana vendor/ua-parser vendor/collectd LICENSE README.md --exclude 'vendor/bundle/jruby/1.9/cache' --exclude 'vendor/bundle/jruby/1.9/gems/*/doc' --exclude 'vendor/jar/elasticsearch-$(ELASTICSEARCH_VERSION).tar.gz' --exclude 'vendor/jar/kafka_$(SCALA_VERSION)-$(KAFKA_VERSION).tgz' $(WORKDIR)
~~~