Skip to content

Don't reference Pathname when building rule sources - #782

Merged
hsbt merged 1 commit into
ruby:masterfrom
sourya2704:fix-rule-pathname-without-require
Dec 3, 2026
Merged

hsbt merged 1 commit into
ruby:masterfrom
sourya2704:fix-rule-pathname-without-require

Conversation

@sourya2704

Copy link
Copy Markdown
Contributor

Fixes #781.

make_sources checked when Pathname before when Proc, Method, so for a proc or method prerequisite the Pathname constant was looked up first. On Ruby versions where pathname hasn't been loaded (3.4 and earlier, unless something else requires it), that raised NameError: uninitialized constant Rake::TaskManager::Pathname.

This checks respond_to?(:to_path) instead, the same way Rake.from_pathname and FileList detect paths, so Pathname prerequisites still work without referencing the constant.

The new functional test runs rake in a separate process with a rule that has a proc prerequisite. It fails on Ruby 3.3 without the change and passes with it.

make_sources checked `when Pathname` before `when Proc, Method`, so a rule with a proc prerequisite raised NameError on Ruby versions where pathname isn't loaded. Check for to_path instead, like Rake.from_pathname does.
@hsbt
hsbt force-pushed the fix-rule-pathname-without-require branch from 63c38c1 to 5883b81 Compare December 3, 2026 07:19
@hsbt
hsbt merged commit 1fd49e2 into ruby:master Dec 3, 2026
40 checks passed
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.

Rake rule with proc always errors on Ruby 3.4

2 participants