summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2024-12-05 17:59:33 +0100
committergit <[email protected]>2024-12-06 15:19:19 +0000
commit48443c02049d6310bd49811911ce5e3d5e9fb0ff (patch)
treed4c7e7ce3abc7f8e5bdf176b63f6357dcbeeaa78 /lib
parentba91ff5f782f008821d61e2e70dfb89751766f2b (diff)
[rubygems/rubygems] Skip unresolved deps warning on `Gem::Specification.reset` on benign cases
If `Gem::Specification.reset` is used, but there are still unresolved dependencies, RubyGems prints a warning. There are though, certain cases where the situation will not cause any issues. One such case is when the unresolved dependency does not restrict any versions (>= 0) and there's a default gem matching it. In this situation, it doesn't matter if Gem paths change, because default gems are still activatable, so the dependency will be properly activated if ever needed. https://github.com/rubygems/rubygems/commit/e5f8a3068e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/specification.rb35
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index aea763abe8..5f1cb92e02 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1199,21 +1199,30 @@ class Gem::Specification < Gem::BasicSpecification
Gem.pre_reset_hooks.each(&:call)
@specification_record = nil
clear_load_cache
- unresolved = unresolved_deps
- unless unresolved.empty?
- warn "WARN: Unresolved or ambiguous specs during Gem::Specification.reset:"
- unresolved.values.each do |dep|
- warn " #{dep}"
-
- versions = find_all_by_name(dep.name).uniq(&:full_name)
- unless versions.empty?
- warn " Available/installed versions of this gem:"
- versions.each {|s| warn " - #{s.version}" }
+
+ unless unresolved_deps.empty?
+ unresolved = unresolved_deps.filter_map do |name, dep|
+ matching_versions = find_all_by_name(name)
+ next if dep.latest_version? && matching_versions.any?(&:default_gem?)
+
+ [dep, matching_versions.uniq(&:full_name)]
+ end.to_h
+
+ unless unresolved.empty?
+ warn "WARN: Unresolved or ambiguous specs during Gem::Specification.reset:"
+ unresolved.each do |dep, versions|
+ warn " #{dep}"
+
+ unless versions.empty?
+ warn " Available/installed versions of this gem:"
+ versions.each {|s| warn " - #{s.version}" }
+ end
end
+ warn "WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
+ warn "Please report a bug if this causes problems."
end
- warn "WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
- warn "Please report a bug if this causes problems."
- unresolved.clear
+
+ unresolved_deps.clear
end
Gem.post_reset_hooks.each(&:call)
end