Skip to content

Rule dependencies' behaviour is strange, possibly broken or poorly documented #626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexeymuranov opened this issue May 7, 2025 · 0 comments

Comments

@alexeymuranov
Copy link

alexeymuranov commented May 7, 2025

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.txt works,
  • rake test.txt fails.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant