Rake rule with proc always errors on Ruby 3.4

Open Beginner friendly
#781 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ruby
Domain
build-system

Research direction

The trace points to lib/rake/task_manager.rb, especially make_sources() around the Pathname case; begin there and check how proc-based rule sources are handled. Reproduce the report with the Ruby 3.4 example and run the relevant task manager tests. Done means the rule with a proc source no longer raises NameError and the tests cover the behavior.

Written by the indexing model from the issue text.

Description

I'm using the latest Arch packages for Ruby and Rake.

$ ruby --version
ruby 3.4.12 (2026-10-23 revision 366f5fdc00) +PRISM [armv7l-linux-eabihf]
$ rake --version
rake, version 13.4.2

The following Rake file does not work:

task :html => ["ch1.html"]

rule '.html' => [-> (name) { 'src/' + name + '.md' }] do
  puts 'foo'
end
$ rake html
rake aborted!
NameError: uninitialized constant Rake::TaskManager::Pathname (NameError)

        when Pathname
             ^^^^^^^^

Tasks: TOP => html
(See full trace by running task with --trace)

The full trace shows that Pathname is used in task_manager.rb without being required. But as I understand it Pathname was only moved into Ruby core in Ruby 4.0.

$ rake html --trace
** Invoke html (first_time)
rake aborted!
NameError: uninitialized constant Rake::TaskManager::Pathname (NameError)

        when Pathname
             ^^^^^^^^
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:305:in 'block in Rake::TaskManager#make_sources'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:294:in 'Array#map'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:294:in 'Rake::TaskManager#make_sources'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:272:in 'Rake::TaskManager#attempt_rule'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:156:in 'block in Rake::TaskManager#enhance_with_matching_rule'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:154:in 'Array#each'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:154:in 'Rake::TaskManager#enhance_with_matching_rule'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task_manager.rb:57:in 'Rake::TaskManager#[]'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:66:in 'Rake::Task#lookup_prerequisite'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:62:in 'block in Rake::Task#prerequisite_tasks'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:62:in 'Array#map'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:62:in 'Rake::Task#prerequisite_tasks'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:241:in 'Rake::Task#invoke_prerequisites'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:218:in 'block in Rake::Task#invoke_with_call_chain'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:199:in 'Monitor#synchronize'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:199:in 'Rake::Task#invoke_with_call_chain'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/task.rb:188:in 'Rake::Task#invoke'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:183:in 'Rake::Application#invoke_task'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:139:in 'block (2 levels) in Rake::Application#top_level'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:139:in 'Array#each'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:139:in 'block in Rake::Application#top_level'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:148:in 'Rake::Application#run_with_threads'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:133:in 'Rake::Application#top_level'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:84:in 'block in Rake::Application#run'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:209:in 'Rake::Application#standard_exception_handling'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/lib/rake/application.rb:81:in 'Rake::Application#run'
/usr/lib/ruby/gems/3.4.0/gems/rake-13.4.2/exe/rake:27:in '<top (required)>'
/usr/bin/rake:25:in 'Kernel#load'
/usr/bin/rake:25:in '<main>'
Tasks: TOP => html

The rule has to have a proc and not just a string. I assume this is because otherwise the string case in make_sources() is matched before the Pathname is hit.

Dominant language
Ruby
Stars
2.5k
Forks
649
Avg merge
4m
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/rake

All issues in ruby/rake

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.