Skip to content

Refactor: Bundler load order and already activated errors #8207

@ph

Description

@ph

I know that some of you have been plagued with already activated error for some time (@jordansissel)

 +Gem::LoadError: You have already activated stud 0.0.23, but your Gemfile requires stud 0.0.24. Prepending `bundle exec` to your command may solve this.
       +  block in setup at /Users/ph/es/logstash/build/logstash-7.0.0-alpha1-SNAPSHOT/vendor/bundle/jruby/2.3.0/gems/bundler-1.9.10/lib/bundler/runtime.rb:34
       +            each at org/jruby/RubyArray.java:1734
       +            each at /Users/ph/es/logstash/build/logstash-7.0.0-alpha1-SNAPSHOT/vendor/jruby/lib/ruby/stdlib/forwardable.rb:189
       +           setup at /Users/ph/es/logstash/build/logstash-7.0.0-alpha1-SNAPSHOT/vendor/bundle/jruby/2.3.0/gems/bundler-1.9.10/lib/bundler/run

I have a pretty good understanding of what is going wrong here; it's related to bundler/RubyGems and your default environment. When no bundler is configured for the current scripts, it will load RubyGems, by default RubyGems will add your local gems path as source and will read the specifications. This can cause already activated errors. This means our Logstash isn't correctly isolated from our local env; this often happens in rake tasks because we are not consistently calling bundler on them.

When working on #8170, I revisited our class and how we load stuff. I believe it's and would not require a lot of big changes.

What needs to be done:

  • Remove the custom name for Gemfile.jruby-2.3.lock
  • Centralize our require of files into a single point, an init or bootstrap file.
  • Revisit to make sure we always activate the bundler environment even if we install

Harder or higher risk:

  • Refactor our install all plugins rake task
  • refactor the install and update to not use bundler's cli class, but either use the resolver or the same logic that we use for x-pack.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions