summaryrefslogtreecommitdiff
path: root/lib
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
parent891ecc63ac5c232081eea9597bbf366239707b77 (diff)
[rubygems/rubygems] Fix `--prefer-local` not respecting default gems
https://github.com/rubygems/rubygems/commit/3df86cd9c6
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--lib/bundler/installer.rb2
-rw-r--r--lib/bundler/source.rb2
-rw-r--r--lib/bundler/source/rubygems.rb21
-rw-r--r--lib/bundler/source_list.rb4
5 files changed, 27 insertions, 4 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index c31682ce4e..c3eae50f65 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -220,6 +220,8 @@ module Bundler
def prefer_local!
@prefer_local = true
+
+ sources.prefer_local!
end
# For given dependency list returns a SpecSet with Gemspec of all the required
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 1cd49d8897..c2da63c822 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -193,7 +193,7 @@ module Bundler
def install(options)
standalone = options[:standalone]
force = options[:force]
- local = options[:local]
+ local = options[:local] || options[:"prefer-local"]
jobs = installation_parallelization
spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
spec_installations.each do |installation|
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 115dbd1378..232873503b 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -35,6 +35,8 @@ module Bundler
spec.source == self
end
+ def prefer_local!; end
+
def local!; end
def local_only!; end
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
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index 343bb73975..b7b2c4209a 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -141,6 +141,10 @@ module Bundler
different_sources?(lock_sources, replacement_sources)
end
+ def prefer_local!
+ all_sources.each(&:prefer_local!)
+ end
+
def local_only!
all_sources.each(&:local_only!)
end