summaryrefslogtreecommitdiff
path: root/lib/bundler
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-12-15 12:41:28 +0100
committergit <svn-admin@ruby-lang.org>2021-12-17 16:35:20 +0900
commit1537471871f9a06624689b55be222f0ea601d140 (patch)
tree1911ddbe1f9ade08f1f5e13f64b92f565afda033 /lib/bundler
parentf3b50507c777522ec5d3e7662c8818df29e29f62 (diff)
downloadruby-1537471871f9a06624689b55be222f0ea601d140.tar.gz
[rubygems/rubygems] Share gem not found logic with transitive dependencies too
https://github.com/rubygems/rubygems/commit/e4a1a9663d
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/resolver.rb58
1 files changed, 30 insertions, 28 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index bccc374e9f..37c27f213d 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -263,30 +263,34 @@ module Bundler
"If you are updating multiple gems in your Gemfile at once,\n" \
"try passing them all to `bundle update`"
else
- source = source_for(name)
- specs = source.specs.search(name)
- matching_part = name
- requirement_label = SharedHelpers.pretty_dependency(requirement)
- cache_message = begin
- " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
- rescue GemfileNotFound
- nil
- end
- specs_matching_requirement = specs.select {| spec| requirement.matches_spec?(spec) }
-
- if specs_matching_requirement.any?
- specs = specs_matching_requirement
- matching_part = requirement_label
- requirement_label = "#{requirement_label} #{requirement.__platform}"
- end
-
- message = String.new("Could not find gem '#{requirement_label}' in #{source}#{cache_message}.\n")
- message << "The source contains the following gems matching '#{matching_part}': #{specs.map(&:full_name).join(", ")}" if specs.any?
+ message = gem_not_found_message(name, requirement, source_for(name))
end
raise GemNotFound, message
end
end
+ def gem_not_found_message(name, requirement, source, extra_message = "")
+ specs = source.specs.search(name)
+ matching_part = name
+ requirement_label = SharedHelpers.pretty_dependency(requirement)
+ cache_message = begin
+ " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
+ rescue GemfileNotFound
+ nil
+ end
+ specs_matching_requirement = specs.select {| spec| requirement.matches_spec?(spec) }
+
+ if specs_matching_requirement.any?
+ specs = specs_matching_requirement
+ matching_part = requirement_label
+ requirement_label = "#{requirement_label} #{requirement.__platform}"
+ end
+
+ message = String.new("Could not find gem '#{requirement_label}'#{extra_message} in #{source}#{cache_message}.\n")
+ message << "The source contains the following gems matching '#{matching_part}': #{specs.map(&:full_name).join(", ")}" if specs.any?
+ message
+ end
+
def version_conflict_message(e)
# only show essential conflicts, if possible
conflicts = e.conflicts.dup
@@ -356,18 +360,16 @@ module Bundler
metadata_requirement = name.end_with?("\0")
- o << "Could not find gem '" unless metadata_requirement
- o << SharedHelpers.pretty_dependency(conflict.requirement)
- o << "'" unless metadata_requirement
- if conflict.requirement_trees.first.size > 1
- o << ", which is required by gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
+ extra_message = if conflict.requirement_trees.first.size > 1
+ ", which is required by gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
+ else
+ ""
end
- o << " "
- o << if metadata_requirement
- "is not available in #{relevant_source}"
+ if metadata_requirement
+ o << "#{SharedHelpers.pretty_dependency(conflict.requirement)}#{extra_message} is not available in #{relevant_source}"
else
- "in #{relevant_source}.\n"
+ o << gem_not_found_message(name, conflict.requirement, relevant_source, extra_message)
end
end
end,