Fix bundled gems warning for all subfeatures of hyphenated gems - #15908
Merged
Conversation
PR ruby#15822 fixed the warning for direct hyphenated gem requires like `benchmark/ips` → `benchmark-ips`. However, hyphenated gems often provide multiple files under their namespace. For example, `benchmark-ips` provides: - benchmark/ips.rb - benchmark/timing.rb - benchmark/compare.rb When requiring `benchmark/timing`, the previous fix only checked for `benchmark-timing` gem (doesn't exist), not `benchmark-ips` which actually provides the file. This fix checks if ANY gem matching `{prefix}-*` is in the bundle specs, which covers all subfeatures provided by hyphenated gems. Reported in ruby#15822 (comment)
hsbt
approved these changes
Feb 12, 2026
hsbt
left a comment
Member
There was a problem hiding this comment.
I consider about resolv-replace-foo case. But I don't know of any famous gems with that name.
I'm +1 to this change. Thanks!
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #15822 - fix incorrect warning for subfeatures of hyphenated gems like
benchmark/timingwhenbenchmark-ipsis in the Gemfile. I've only checked loading ips, but wasn't enough 😅Problem
After #15822, users still get warnings when using gems like
benchmark-ips:This happens because
benchmark-ipsprovides multiple files:benchmark/ips.rbbenchmark/timing.rbbenchmark/compare.rbThe fix in #15822 only checks for exact hyphenated match (
benchmark/timing→benchmark-timing), butbenchmark-timinggem doesn't exist.Solution
Instead of checking for exact hyphenated gem name, check if ANY gem matching
{prefix}-*is in the bundle specs:Test
Added test case for
benchmark/timingandbenchmark/comparewithbenchmark-ipsin specs.