logstash-plugins / logstash-filter-date

Apache License 2.0
7 stars 43 forks source link

Use Ruby parent environment bundle instead of system's one #159

Closed andsel closed 1 year ago

andsel commented 1 year ago

The Rakefile script defines a vendor task which determines the Logstash path issuing the command:

lsc_path = `bundle show logstash-core`

This command executes the bundle associated with the system's Ruby environment. If the rake vendor task is executed from another (not the default Ruby) Ruby installation, then this spawned bundler must be the coming from the launching Ruby distribution.

Otherwise the environment shouldn't have all the expected gems installed and return an error similar to:

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 /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler/rubygems_integration.rb:178
    set_bundle_variables at /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler/shared_helpers.rb:282
  set_bundle_environment at /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler/shared_helpers.rb:76
                   setup at /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler/runtime.rb:20
                   setup at /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler.rb:161
                  <main> at /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler/setup.rb:20
              with_level at /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler/ui/shell.rb:136
                 silence at /Users/andrea/workspace/logstash_andsel/vendor/jruby/lib/ruby/stdlib/bundler/ui/shell.rb:88
                  <main> at /Users/andrea/workspace/logstash_andsel/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=

This error prohibit to properly populate the path logstashCoreGemPath in gradle.properties and fail the subsequent execution of ./gradlew vendor


Related https://github.com/elastic/logstash/pull/15511