module Dependabot::Bundler::NativeHelpers

Public Class Methods

helper_path(bundler_version:) click to toggle source
# File lib/dependabot/bundler/native_helpers.rb, line 38
def self.helper_path(bundler_version:)
  "bundle exec ruby #{File.join(versioned_helper_path(bundler_version: bundler_version), 'run.rb')}"
end
native_helpers_root() click to toggle source
# File lib/dependabot/bundler/native_helpers.rb, line 42
def self.native_helpers_root
  helpers_root = ENV["DEPENDABOT_NATIVE_HELPERS_PATH"]
  return File.join(helpers_root, "bundler") unless helpers_root.nil?

  File.join(__dir__, "../../../helpers")
end
run_bundler_subprocess(function:, args:, bundler_version:) click to toggle source
# File lib/dependabot/bundler/native_helpers.rb, line 9
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_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_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_major_version), ".bundle")
      }
    )
  rescue SharedHelpers::HelperSubprocessFailed => e
    # TODO: Remove once we stop stubbing out the V2 native helper
    raise Dependabot::NotImplemented, e.message if e.error_class == "Functions::NotImplementedError"

    raise
  end
end
versioned_helper_path(bundler_version:) click to toggle source
# File lib/dependabot/bundler/native_helpers.rb, line 33
def self.versioned_helper_path(bundler_version:)
  native_helper_version = "v#{bundler_version}"
  File.join(native_helpers_root, native_helper_version)
end