Rule dependencies' behaviour is strange, possibly broken or poorly documented
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.5k
- Forks
- 650
- Avg merge
- 6m
- Merged PRs (30d)
- 3
Description
Consider this Rakefile:
require 'rake/clean'
task default: :test
task test: 'test.txt'
file 'test.txt' => 'test0.txt'
rule '.txt' => '.pre' do |t|
sh 'cp', t.source, t.name
end
rule '.pre' do |t|
sh 'touch', t.name
end
CLEAN.include('*.pre')
CLOBBER.include('*.txt')
This Rakefile demonstrates 2 related issues.
The implicit dependency test.pre is not built automatically
In a folder containing only this Rakefile, try:
$ rake
touch test0.pre
cp test0.pre test0.txt
cp test.pre test.txt
cp: cannot stat 'test.pre': No such file or directory
rake aborted!
Command failed with status (1): [cp test.pre test.txt...]
[...]
This creates test0.pre and test0.txt, but fails to create test.pre and test.txt.
However, the following sequence of commands works without issues:
$ rake test.pre
touch test.pre
$ rake
touch test0.pre
cp test0.pre test0.txt
cp test.pre test.txt
Thus, rake knows how to build test.pre, but skips it unless asked explicitly.
Note that despite skipping test.pre, rake builds test0.pre automatically, while both are dependencies by the same rule.
In fact, starting from a folder containing only this Rakefile,
rake test0.txtworks,rake test.txtfails.
Updating test.pre does not trigger rebuilding of test.txt
Assume that everything has been built with
$ rake test.pre
$ rake
Now, try this:
$ touch test.pre
$ rake
Nothing happens.
Now, try:
$ touch test0.pre
$ rake
cp test0.pre test0.txt
cp test.pre test.txt
This triggers rebuilding.
Rake version
rake version: 13.0.6.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report from the provided Rakefile, first running rake, rake test.pre, rake test0.txt, and rake test.txt, then repeat after touching test.pre and test0.pre. Trace Rake's rule dependency resolution and timestamp handling. Done means the dependency behavior is corrected or clearly documented, with regression coverage for both cases.
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
- 38/100