diff options
| author | Chris HasiĆski <krzysztof.hasinski@gmail.com> | 2026-01-08 01:13:38 +0100 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2026-01-08 13:15:29 +0900 |
| commit | 768862868472fb1800e556effb0e37be2fbaec52 (patch) | |
| tree | b82c39a1e6d993f3838cd6834af10be5a83b1765 /lib | |
| parent | 080d66beca71d6cc290a8be4acd49e5a70594f9c (diff) | |
Fix incorrect bundled gems warning for hyphenated gem names
When requiring a file like "benchmark/ips", the warning system would
incorrectly warn about the "benchmark" gem not being a default gem,
even when the user has "benchmark-ips" (a separate third-party gem)
in their Gemfile.
The fix checks if a hyphenated version of the require path exists in
the bundle specs before issuing a warning. For example, requiring
"benchmark/ips" now checks for both "benchmark" and "benchmark-ips"
in the Gemfile.
[Bug #21828]
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bundled_gems.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb index 49fb90249d..3ac10aa256 100644 --- a/lib/bundled_gems.rb +++ b/lib/bundled_gems.rb @@ -124,6 +124,16 @@ module Gem::BUNDLED_GEMS # :nodoc: return if specs.include?(name) + # Don't warn if a hyphenated gem provides this feature + # (e.g., benchmark-ips provides benchmark/ips, not the benchmark gem) + if subfeature + feature_parts = feature.split("/") + if feature_parts.size >= 2 + hyphenated_gem = "#{feature_parts[0]}-#{feature_parts[1]}" + return if specs.include?(hyphenated_gem) + end + end + return if WARNED[name] WARNED[name] = true |
