ruby / ruby/rake

Shared multitask prerequisite intermittently executed multiple times

Open
#274 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.5k
Forks
650
Avg merge
6m
Merged PRs (30d)
3

Description

Given a Rakefile

multitask :default => [:a, :b, :c, :d, :e]

task :a => ['target']
task :b => ['target']
task :c => ['target']
task :d => ['target']
task :e => ['target']

rule(/^target$/ => [ 'source' ]) do |t|
    p "#{t.name} => #{t.source}"
    p t.actions
end

file 'source'

the target may get executed multiple times like this

$ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-musl]
$ rake --version
rake, version 12.3.1
$ rake --trace --rules
** Invoke default (first_time)
** Invoke a (first_time)
Attempting Rule target => source
** Invoke b (first_time)
Attempting Rule target => source
** Invoke c (first_time)
Attempting Rule target => source
** Invoke d (first_time)
Attempting Rule target => source
(target => source ... EXIST)
** Invoke e (first_time)
Attempting Rule target => source
(target => source ... EXIST)
(target => source ... EXIST)
** Invoke target (first_time)
(target => source ... EXIST)
** Invoke source (first_time)
(target => source ... EXIST)
** Execute source
** Execute target
"target => source"
[#<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>]
"target => source"
[#<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>]
"target => source"
[#<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>]
"target => source"
[#<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>]
"target => source"
[#<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>, #<Proc:0x000055e092b971c0@/repo/Rakefile:10>]
** Execute d
** Invoke target 
** Execute b
** Invoke target 
** Execute a
** Invoke target 
** Execute c
** Invoke target 
** Execute e
** Execute default

The results differ between runs. It seems to happen more often with debug output.

The same action block gets added multiple times to the same task.

Contributor guide

Open the contributing guide

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.

Research direction

Reproduce the issue with the supplied Rakefile using rake --trace --rules, varying debug output and repeated runs. Trace the multitask and rule-resolution entry points to determine why the same action is added repeatedly; done means the shared target action executes once consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.