Rake rule with proc always errors on Ruby 3.4

オープン 初心者向け
#781 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
ruby
領域
build-system

調査の方向性

トレースは lib/rake/task_manager.rb、特に Pathname のケース周辺にある make_sources() を示しています。そこから始めて、proc ベースのルールソースがどのように処理されるかを確認してください。Ruby 3.4 の例で報告内容を再現し、該当するタスクマネージャーのテストを実行してください。proc ソースを持つルールが NameError を発生させなくなり、テストでその動作がカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Ruby
スター
2.5k
フォーク
649
平均マージ
4分
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/rake のほかの issue

ruby/rake の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。