Skip to content

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

Open
sourya2704 wants to merge 1 commit into
ruby:masterfrom
sourya2704:fix-rule-pathname-without-require
Open

sourya2704 wants to merge 1 commit into
ruby:masterfrom
sourya2704:fix-rule-pathname-without-require

Conversation

@sourya2704

Copy link
Copy Markdown

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.

This branch has not been deployed

No deployments
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

1 participant