diff --git a/bundler/lib/dependabot/bundler/native_helpers.rb b/bundler/lib/dependabot/bundler/native_helpers.rb index 1b743597b93..d5f7bfdf309 100644 --- a/bundler/lib/dependabot/bundler/native_helpers.rb +++ b/bundler/lib/dependabot/bundler/native_helpers.rb @@ -17,7 +17,9 @@ def self.run_bundler_subprocess(function:, args:, bundler_version:) # 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_PATH" => File.join(versioned_helper_path(bundler_version: bundler_version), ".bundle") + "BUNDLE_PATH" => File.join(versioned_helper_path(bundler_version: bundler_version), ".bundle"), + # 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") } ) end