logstash-plugins / logstash-filter-date

Apache License 2.0
7 stars 43 forks source link

Retrieve logstash-core gem's path using inline bundler #160

Closed andsel closed 1 year ago

andsel commented 1 year ago

Release notes

[rn:skip]

What does this PR do?

Avoid to fork a bundler process to extract logstash-core's path and use the same bundler that wraps the execution of the Rakefile itself.

Why is it important/What is the impact to the user?

All the Rake tasks must run with same JRuby distribution that launched the execution. Without this, it uses the system's Ruby.

Checklist

Author's Checklist

How to test this PR locally

Verify that it works with Logstash JRuby distribution:

export LOGSTASH_PATH=/tmp/logstash/ && export LOGSTASH_SOURCE=1
/tmp/logstash/bin/ruby -S bundle install
/tmp/logstash/bin/ruby -S exec rake vendor

Related issues

Use cases

Screenshots

Logs

If not configured int his way, running /tmp/logstash/bin/ruby -S exec rake vendor would rise:

andrea:logstash-filter-date (main) % rm gradle.properties && /tmp/logstash/bin/ruby -S bundle exec rake vendor
Using system java: /Users/andrea/.sdkman/candidates/java/current/bin/java
Processing jvm.options file at `/tmp/logstash/config/jvm.options`
Using GEM_HOME=/tmp/logstash/vendor/bundle/jruby/3.1.0
Using GEM_PATH=/tmp/logstash/vendor/bundle/jruby/3.1.0
DEBUG: exec /tmp/logstash/vendor/jruby/bin/jruby -S bundle exec rake vendor

Gem::GemNotFoundException: can't find gem bundler (= 2.3.26) with executable bundle
       find_spec_for_exe at /Users/andrea/.rvm/rubies/jruby-9.4.2.0/lib/ruby/stdlib/rubygems.rb:265
                bin_path at /Users/andrea/.rvm/rubies/jruby-9.4.2.0/lib/ruby/stdlib/rubygems.rb:245
                bin_path at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/rubygems_integration.rb:178
    set_bundle_variables at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/shared_helpers.rb:282
  set_bundle_environment at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/shared_helpers.rb:76
                   setup at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/runtime.rb:20
                   setup at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler.rb:161
                  <main> at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/setup.rb:20
              with_level at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/ui/shell.rb:136
                 silence at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/ui/shell.rb:88
                  <main> at /tmp/logstash/vendor/jruby/lib/ruby/stdlib/bundler/setup.rb:20
                 require at org/jruby/RubyKernel.java:1057
                 require at /Users/andrea/.rvm/rubies/jruby-9.4.2.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
-------------------> Wrote /Users/andrea/workspace/logstash_plugins/logstash-filter-date/gradle.properties
logstashCoreGemPath=