diff --git a/bundler/helpers/v1/build b/bundler/helpers/v1/build index 812b687852..963f151b32 100755 --- a/bundler/helpers/v1/build +++ b/bundler/helpers/v1/build @@ -20,6 +20,6 @@ cd "$install_dir" # NOTE: Sets `BUNDLED WITH` to match the installed v1 version in Gemfile.lock # forcing native helpers to run with the same version -BUNDLER_VERSION=1 bundle config set --local path ".bundle" -BUNDLER_VERSION=1 bundle config set --local without "test" -BUNDLER_VERSION=1 bundle install +BUNDLER_VERSION=1.17.3 bundle config set --local path ".bundle" +BUNDLER_VERSION=1.17.3 bundle config set --local without "test" +BUNDLER_VERSION=1.17.3 bundle install diff --git a/bundler/helpers/v2/build b/bundler/helpers/v2/build index aeaac5d027..a09da33b0e 100755 --- a/bundler/helpers/v2/build +++ b/bundler/helpers/v2/build @@ -20,6 +20,6 @@ cd "$install_dir" # NOTE: Sets `BUNDLED WITH` to match the installed v2 version in Gemfile.lock # forcing specs and native helpers to run with the same version -BUNDLER_VERSION=2 bundle config set --local path ".bundle" -BUNDLER_VERSION=2 bundle config set --local without "test" -BUNDLER_VERSION=2 bundle install +BUNDLER_VERSION=2.2.26 bundle config set --local path ".bundle" +BUNDLER_VERSION=2.2.26 bundle config set --local without "test" +BUNDLER_VERSION=2.2.26 bundle install diff --git a/bundler/lib/dependabot/bundler/helpers.rb b/bundler/lib/dependabot/bundler/helpers.rb index e77f9f3f31..64d6cb7a2a 100644 --- a/bundler/lib/dependabot/bundler/helpers.rb +++ b/bundler/lib/dependabot/bundler/helpers.rb @@ -3,8 +3,8 @@ module Dependabot module Bundler module Helpers - V1 = "1" - V2 = "2" + V1 = "1.17.3" + V2 = "2.2.26" # If we are updating a project with no Gemfile.lock, we default to the # newest version we support DEFAULT = V2 @@ -31,7 +31,7 @@ def self.detected_bundler_version(lockfile) if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX)) matches[:version] else - FAILOVER + "1" end end end diff --git a/bundler/lib/dependabot/bundler/native_helpers.rb b/bundler/lib/dependabot/bundler/native_helpers.rb index 1d9a1b76c1..5f9489fc31 100644 --- a/bundler/lib/dependabot/bundler/native_helpers.rb +++ b/bundler/lib/dependabot/bundler/native_helpers.rb @@ -8,17 +8,18 @@ module Bundler module NativeHelpers def self.run_bundler_subprocess(function:, args:, bundler_version:) # Run helper suprocess with all bundler-related ENV variables removed + bundler_major_version = bundler_version.split(".").first ::Bundler.with_original_env do SharedHelpers.run_helper_subprocess( - command: helper_path(bundler_version: bundler_version), + command: helper_path(bundler_version: bundler_major_version), function: function, args: args, env: { # Bundler will pick the matching installed major version "BUNDLER_VERSION" => bundler_version, - "BUNDLE_GEMFILE" => File.join(versioned_helper_path(bundler_version: bundler_version), "Gemfile"), + "BUNDLE_GEMFILE" => File.join(versioned_helper_path(bundler_version: bundler_major_version), "Gemfile"), # Prevent the GEM_HOME from being set to a folder owned by root - "GEM_HOME" => File.join(versioned_helper_path(bundler_version: bundler_version), ".bundle") + "GEM_HOME" => File.join(versioned_helper_path(bundler_version: bundler_major_version), ".bundle") } ) rescue SharedHelpers::HelperSubprocessFailed => e diff --git a/bundler/script/ci-test b/bundler/script/ci-test index 11ff34ae9e..b88b4f596d 100755 --- a/bundler/script/ci-test +++ b/bundler/script/ci-test @@ -8,14 +8,14 @@ bundle exec rspec spec if [[ "$SUITE_NAME" == "bundler1" ]]; then cd helpers/v1 \ - && BUNDLER_VERSION=1 bundle install \ - && BUNDLER_VERSION=1 bundle exec rspec spec\ + && BUNDLER_VERSION=1.17.3 bundle install \ + && BUNDLER_VERSION=1.17.3 bundle exec rspec spec\ && cd - fi if [[ "$SUITE_NAME" == "bundler2" ]]; then cd helpers/v2 \ - && BUNDLER_VERSION=2 bundle install \ - && BUNDLER_VERSION=2 bundle exec rspec spec \ + && BUNDLER_VERSION=2.2.26 bundle install \ + && BUNDLER_VERSION=2.2.26 bundle exec rspec spec \ && cd - fi diff --git a/bundler/spec/dependabot/bundler/file_parser_spec.rb b/bundler/spec/dependabot/bundler/file_parser_spec.rb index 3c86ae50c7..94dd536341 100644 --- a/bundler/spec/dependabot/bundler/file_parser_spec.rb +++ b/bundler/spec/dependabot/bundler/file_parser_spec.rb @@ -759,7 +759,7 @@ parser.parse expect(events.last.payload).to eq( - { ecosystem: "bundler", package_managers: { "bundler" => PackageManagerHelper.bundler_version } } + { ecosystem: "bundler", package_managers: { "bundler" => PackageManagerHelper.bundler_major_version } } ) end end diff --git a/bundler/spec/dependabot/bundler/helper_spec.rb b/bundler/spec/dependabot/bundler/helper_spec.rb index d9b88a0671..e8cde162e7 100644 --- a/bundler/spec/dependabot/bundler/helper_spec.rb +++ b/bundler/spec/dependabot/bundler/helper_spec.rb @@ -40,29 +40,32 @@ LOCKFILE end + let(:v1) { "1.17.3" } + let(:v2) { "2.2.26" } + describe "#bundler_version" do def described_method(lockfile) described_class.bundler_version(lockfile) end it "is 2 if there is no lockfile" do - expect(described_method(no_lockfile)).to eql("2") + expect(described_method(no_lockfile)).to eql(v2) end it "is 1 if there is no bundled with string" do - expect(described_method(lockfile_bundled_with_missing)).to eql("1") + expect(described_method(lockfile_bundled_with_missing)).to eql(v1) end it "is 1 if it was bundled with a v1.x version" do - expect(described_method(lockfile_bundled_with_v1)).to eql("1") + expect(described_method(lockfile_bundled_with_v1)).to eql(v1) end it "is 2 if it was bundled with a v2.x version" do - expect(described_method(lockfile_bundled_with_v2)).to eql("2") + expect(described_method(lockfile_bundled_with_v2)).to eql(v2) end it "is 2 if it was bundled with a future version" do - expect(described_method(lockfile_bundled_with_future_version)).to eql("2") + expect(described_method(lockfile_bundled_with_future_version)).to eql(v2) end end diff --git a/bundler/spec/spec_helper.rb b/bundler/spec/spec_helper.rb index 18d34b7785..c462d1342f 100644 --- a/bundler/spec/spec_helper.rb +++ b/bundler/spec/spec_helper.rb @@ -20,12 +20,16 @@ def self.use_bundler_2? end def self.bundler_version - use_bundler_2? ? "2" : "1" + use_bundler_2? ? "2.2.26" : "1.17.3" + end + + def self.bundler_major_version + bundler_version.split(".").first end end def bundler_project_dependency_files(project) - project_dependency_files(File.join("bundler#{PackageManagerHelper.bundler_version}", project)) + project_dependency_files(File.join("bundler#{PackageManagerHelper.bundler_major_version}", project)) end def bundler_project_dependency_file(project, filename:)