Skip to content

Pass the require path to find_by_path - #1343

Open
apiology wants to merge 1 commit into
castwide:masterfrom
apiology:resolve-require-requirable-path
Open

Pass the require path to find_by_path#1343
apiology wants to merge 1 commit into
castwide:masterfrom
apiology:resolve-require-requirable-path

Conversation

@apiology

@apiology apiology commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Problem: Gem::Specification.find_by_path matches a requirable path — the same string that appears in a require statement. resolve_require was handing it a lib-relative filename instead, which it can never match, so that lookup always returned nil.

Gem::Specification.find_by_path("yard")         # => the yard gemspec
Gem::Specification.find_by_path("lib/yard.rb")  # => nil

Resolution then fell through to guessing the gem name from the require path and, failing that, scanning every bundled gemspec and reading its file list.

Solution: Pass the require path itself, and move the lib-relative filename down to the manual spec.files scan, which is the only remaining reader of it.

🤖 Generated with Claude Code

Gem::Specification.find_by_path matches a requirable path, the same
string that appears in a require statement. resolve_require was handing
it "lib/#{require}.rb" instead, which it can never match, so the lookup
always returned nil and resolution fell through to guessing the gem name
from the path and then scanning every bundled gemspec.

Pass the require path itself, and move the lib-relative filename down to
the manual spec.files scan that is the only remaining reader of it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant