Skip to content

Commit

Permalink
Improve error message if only platform doesn't match
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Dec 15, 2021
1 parent 75121e8 commit 077e3c2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bundler/lib/bundler/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,23 @@ def verify_gemfile_dependencies_are_found!(requirements)
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
message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
message << "The source contains the following gems matching '#{name}': #{specs.map(&:full_name).join(", ")}" if specs.any?
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?
end
raise GemNotFound, message
end
Expand Down

0 comments on commit 077e3c2

Please sign in to comment.