From a55874406cb1be41073c6353052bb88d44123217 Mon Sep 17 00:00:00 2001 From: Anthony Panozzo Date: Mon, 5 Jan 2026 13:04:14 -0500 Subject: [ruby/rubygems] Add backwards compatibility for Bundler with older RubyGems Guard against missing Gem.global_gem_cache_path method when Bundler is used with an older RubyGems version that doesn't have the global cache feature. Falls back to the previous Bundler.user_cache location. Suggested by skipkayhil. https://github.com/ruby/rubygems/commit/a4bb3a20f8 --- lib/bundler/source/rubygems.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 1ad1a74fbd..e679010e97 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -504,7 +504,12 @@ module Bundler return unless remote = spec.remote return unless cache_slug = remote.cache_slug - Pathname.new(Gem.global_gem_cache_path).join(cache_slug) + if Gem.respond_to?(:global_gem_cache_path) + Pathname.new(Gem.global_gem_cache_path).join(cache_slug) + else + # Fall back to old location for older RubyGems versions + Bundler.user_cache.join("gems", cache_slug) + end end def extension_cache_slug(spec) -- cgit v1.2.3