Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set BUNDLER_VERSION to the specific installed version in native helpers #5044

Merged
merged 3 commits into from
Apr 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions bundler/lib/dependabot/bundler/native_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def clamp(seconds)
def self.run_bundler_subprocess(function:, args:, bundler_version:, options: {})
# Run helper suprocess with all bundler-related ENV variables removed
bundler_major_version = bundler_version.split(".").first
helpers_path = versioned_helper_path(bundler_version: bundler_major_version)
helpers_path = versioned_helper_path(bundler_major_version)
::Bundler.with_original_env do
command = BundleCommand.
new(options[:timeout_per_operation_seconds]).
Expand All @@ -47,7 +47,7 @@ def self.run_bundler_subprocess(function:, args:, bundler_version:, options: {})
args: args,
env: {
# Bundler will pick the matching installed major version
"BUNDLER_VERSION" => bundler_version,
"BUNDLER_VERSION" => installed_bundler_version(bundler_major_version),
"BUNDLE_GEMFILE" => File.join(helpers_path, "Gemfile"),
# Prevent the GEM_HOME from being set to a folder owned by root
"GEM_HOME" => File.join(helpers_path, ".bundle")
Expand All @@ -61,8 +61,15 @@ def self.run_bundler_subprocess(function:, args:, bundler_version:, options: {})
end
end

def self.versioned_helper_path(bundler_version:)
File.join(native_helpers_root, "v#{bundler_version}")
def self.versioned_helper_path(bundler_major_version)
File.join(native_helpers_root, "v#{bundler_major_version}")
end

# Maps the major version unto the specific version we have installed
def self.installed_bundler_version(bundler_major_version)
return Helpers::V1 if bundler_major_version == "1"

Helpers::V2
end

def self.native_helpers_root
Expand Down