summaryrefslogtreecommitdiff
path: root/lib/bundler/source
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2025-01-15 16:50:14 +0100
committerHiroshi SHIBATA <[email protected]>2025-01-20 13:50:27 +0900
commitee7b74799ca2de454fb708a70a0b2e30b46e8f57 (patch)
treea51efc8572c93ecc1d30e93b44e8a09c47efb9b1 /lib/bundler/source
parent891ecc63ac5c232081eea9597bbf366239707b77 (diff)
[rubygems/rubygems] Fix `--prefer-local` not respecting default gems
https://github.com/rubygems/rubygems/commit/3df86cd9c6
Diffstat (limited to 'lib/bundler/source')
-rw-r--r--lib/bundler/source/rubygems.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 36185561fa..f1d6dcb3b9 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -19,6 +19,7 @@ module Bundler
@allow_remote = false
@allow_cached = false
@allow_local = options["allow_local"] || false
+ @prefer_local = false
@checksum_store = Checksum::Store.new
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
@@ -30,6 +31,10 @@ module Bundler
@caches ||= [cache_path, *Bundler.rubygems.gem_cache]
end
+ def prefer_local!
+ @prefer_local = true
+ end
+
def local_only!
@specs = nil
@allow_local = true
@@ -37,6 +42,10 @@ module Bundler
@allow_remote = false
end
+ def local_only?
+ @allow_local && !@allow_remote
+ end
+
def local!
return if @allow_local
@@ -139,9 +148,15 @@ module Bundler
index.merge!(cached_specs) if @allow_cached
index.merge!(installed_specs) if @allow_local
- # complete with default specs, only if not already available in the
- # index through remote, cached, or installed specs
- index.use(default_specs) if @allow_local
+ if @allow_local
+ if @prefer_local
+ index.merge!(default_specs)
+ else
+ # complete with default specs, only if not already available in the
+ # index through remote, cached, or installed specs
+ index.use(default_specs)
+ end
+ end
index
end