Skip to content

Commit

Permalink
Revert "remove forced dependency on old bundler (elastic#9395)"
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvd committed Dec 3, 2018
1 parent 904494f commit bef9841
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 30 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ def qaBundledGemPath = "${qaVendorPath}/jruby/2.3.0"
def qaBundleBin = "${qaBundledGemPath}/bin/bundle"

task installIntegrationTestBundler(dependsOn: unpackTarDistribution) {
outputs.files fileTree("${qaBundledGemPath}/gems/bundler-1.17.1")
outputs.files fileTree("${qaBundledGemPath}/gems/bundler-1.16.0")
doLast {
rubyGradleUtils.gem("bundler", "1.17.1", qaBundledGemPath)
rubyGradleUtils.gem("bundler", "1.16.0", qaBundledGemPath)
}
}

Expand Down
35 changes: 15 additions & 20 deletions lib/bootstrap/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ def patch!
# Patch to prevent Bundler to save a .bundle/config file in the root
# of the application
::Bundler::Settings.module_exec do
def set_local(key, value)
set_key(key, value, @local_config, nil)
end
end
def set_key(key, value, hash, file)
key = key_for(key)

unless hash[key] == value
hash[key] = value
hash.delete(key) if value.nil?
end

# In recent versions (currently 1.17.1) Bundler calls reset_paths! early during
# Bundler::CLI.start (https://github.com/bundler/bundler/blob/v1.17.1/lib/bundler/cli.rb#L39)
# This breaks our setting up of gemfile and bundle paths, the without group setting etc
# We need to tone down this very aggressive resetter (https://github.com/bundler/bundler/blob/v1.17.1/lib/bundler.rb#L487-L500)
# So we reimplement it here to only nullify the definition object, so that it can be computed
# again if necessary with all the configuration in place.
::Bundler.module_exec do
def self.reset_paths!
@definition = nil
value
end
end

Expand Down Expand Up @@ -52,11 +47,11 @@ def setup!(options = {})
require "bundler"
LogStash::Bundler.patch!

::Bundler.settings.set_local(:path, Environment::BUNDLE_DIR)
::Bundler.settings.set_local(:without, options[:without])
::Bundler.settings[:path] = Environment::BUNDLE_DIR
::Bundler.settings[:without] = options[:without].join(":")
# in the context of Bundler.setup it looks like this is useless here because Gemfile path can only be specified using
# the ENV, see https://github.com/bundler/bundler/blob/v1.8.3/lib/bundler/shared_helpers.rb#L103
::Bundler.settings.set_local(:gemfile, Environment::GEMFILE_PATH)
::Bundler.settings[:gemfile] = Environment::GEMFILE_PATH

::Bundler.reset!
::Bundler.setup
Expand Down Expand Up @@ -108,10 +103,10 @@ def invoke!(options = {})
# force Rubygems sources to our Gemfile sources
::Gem.sources = ::Gem::SourceList.from(options[:rubygems_source]) if options[:rubygems_source]

::Bundler.settings.set_local(:path, LogStash::Environment::BUNDLE_DIR)
::Bundler.settings.set_local(:gemfile, LogStash::Environment::GEMFILE_PATH)
::Bundler.settings.set_local(:without, options[:without])
::Bundler.settings.set_local(:force, options[:force])
::Bundler.settings[:path] = LogStash::Environment::BUNDLE_DIR
::Bundler.settings[:gemfile] = LogStash::Environment::GEMFILE_PATH
::Bundler.settings[:without] = options[:without].join(":")
::Bundler.settings[:force] = options[:force]

if !debug?
# Will deal with transient network errors
Expand Down
2 changes: 1 addition & 1 deletion lib/pluginmanager/bundler/logstash_injector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def inject(gemfile_path, lockfile_path, dependencies)
gemfile = LogStash::Gemfile.new(File.new(gemfile_path, "r+")).load

begin
@deps.each do |dependency|
@new_deps.each do |dependency|
gemfile.update(dependency.name, dependency.requirement)
end

Expand Down
4 changes: 2 additions & 2 deletions qa/integration/specs/cli/remove_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

expect(execute.exit_code).to eq(1)
expect(execute.stderr_and_stdout).to match(/Failed to remove "logstash-codec-json"/)
expect(execute.stderr_and_stdout).to match(/logstash-input-kafka/) # one of the dependency
expect(execute.stderr_and_stdout).to match(/logstash-input-beats/) # one of the dependency
expect(execute.stderr_and_stdout).to match(/logstash-output-udp/) # one of the dependency

presence_check = @logstash_plugin.list("logstash-codec-json")
Expand Down Expand Up @@ -78,7 +78,7 @@

expect(execute.exit_code).to eq(1)
expect(execute.stderr_and_stdout).to match(/Failed to remove "logstash-codec-json"/)
expect(execute.stderr_and_stdout).to match(/logstash-input-kafka/) # one of the dependency
expect(execute.stderr_and_stdout).to match(/logstash-input-beats/) # one of the dependency
expect(execute.stderr_and_stdout).to match(/logstash-output-udp/) # one of the dependency

presence_check = @logstash_plugin.list("logstash-codec-json")
Expand Down
1 change: 0 additions & 1 deletion rakelib/artifacts.rake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace "artifact" do
"logstash-core/*.gemspec",

"logstash-core-plugin-api/lib/**/*",
"logstash-core-plugin-api/versions-gem-copy.yml",
"logstash-core-plugin-api/*.gemspec",

"patterns/**/*",
Expand Down
2 changes: 1 addition & 1 deletion rakelib/dependency.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

namespace "dependency" do
task "bundler" do
Rake::Task["gem:require"].invoke("bundler", "~> 1.17.1")
Rake::Task["gem:require"].invoke("bundler", "~> 1.9.4")
end

task "clamp" do
Expand Down
2 changes: 2 additions & 0 deletions rakelib/vendor.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace "vendor" do
system('./gradlew downloadAndInstallJRuby') unless File.exists?(File.join("vendor", "jruby"))
end # jruby

task "all" => "jruby"

namespace "force" do
task "gems" => ["vendor:gems"]
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/bootstrap/bundler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
after do
expect(::Bundler.settings[:path]).to eq(LogStash::Environment::BUNDLE_DIR)
expect(::Bundler.settings[:gemfile]).to eq(LogStash::Environment::GEMFILE_PATH)
expect(::Bundler.settings[:without]).to eq(options.fetch(:without, []))
expect(::Bundler.settings[:without]).to eq(options.fetch(:without, []).join(':'))

expect(ENV['GEM_PATH']).to eq(LogStash::Environment.logstash_gem_home)

Expand Down
3 changes: 1 addition & 2 deletions spec/unit/license_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
# Skipped because version 2.6.2 which we use has multiple licenses: MIT, ARTISTIC 2.0, GPL-2
# See https://rubygems.org/gems/mime-types/versions/2.6.2
# version 3.0 of mime-types (which is only compatible with Ruby 2.0) is MIT licensed
"mime-types",
"logstash-core-plugin-api"
"mime-types"
]
end

Expand Down

0 comments on commit bef9841

Please sign in to comment.