Rake rule with proc always errors on Ruby 3.4

Đang mở Phù hợp với người mới
#781 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ruby
Lĩnh vực
build-system

Hướng nghiên cứu

Trace chỉ đến lib/rake/task_manager.rb, đặc biệt là make_sources() quanh trường hợp Pathname; hãy bắt đầu từ đó và kiểm tra cách xử lý các nguồn quy tắc dựa trên proc. Tái hiện báo cáo bằng ví dụ Ruby 3.4 và chạy các bài kiểm thử task manager liên quan. Công việc hoàn tất khi quy tắc có nguồn proc không còn gây ra NameError và các bài kiểm thử bao quát hành vi này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Ruby
Star
2.5k
Fork
649
Merge trung bình
4 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/rake

Tất cả issue của ruby/rake

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.