Do you have a “build script” (build.rs)? Use rerun-if-changed by default


#1

This should be in your build.rs by default (unless you need something else, depend on other files).

println!("cargo:rerun-if-changed=build.rs");

See docs, which talks about the behaviour if you don’t use this:

Normally build scripts are re-run if any file inside the crate root changes.

My emphasis. Without it you get more nonsensical rebuilds of the whole project.


Simple project recompiles all dependencies when files change
#2

You know, I think this falls squarely into “obscure stuff you need to somehow know to not get correct-but-rubbish behaviour” territory.

Perhaps Cargo could learn to accept rerun-if-changed=* for the current behaviour, and warn when you directly build (i.e. not as a dependency) any package which both has a build script and doesn’t specify at least one rerun-if-changed line.


#3

Yes, but there is a reason of course: backwards compatibility. Your solution with a warning is good. Either way, we need to get this info out, so that it’s being added everywhere.