Rake rule with proc always errors on Ruby 3.4

Aberta Para iniciantes
#781 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
ruby
Domínio
build-system

Direção de pesquisa

O trace aponta para lib/rake/task_manager.rb, especialmente para make_sources() em torno do caso Pathname; comece por aí e verifique como as fontes de regras baseadas em proc são tratadas. Reproduza o relato com o exemplo do Ruby 3.4 e execute os testes relevantes do gerenciador de tarefas. O trabalho estará concluído quando a regra com uma fonte proc não gerar mais NameError e os testes cobrirem esse comportamento.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Ruby
Estrelas
2.5k
Forks
649
Merge médio
4min
PRs com merge (30d)
5

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de ruby/rake

Todas as issues de ruby/rake

Issues semelhantes

Mais issues de Ruby

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.