-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
rerun-if-env-changed=CARGO_MANIFEST_DIR changing doesn't trigger a rebuild on change #8693
Comments
@alecmocatta which version of rustc and cargo did you try this with? |
Latest nightly, 2020-09-09 |
This is an issue (or non-issue) with cargo rather than rustc. |
Yes sorry this is a potential issue with cargo, I was too hasty in my filing here. Is it possible to move the issue? Alternately as this is a known issue as @RalfJung tracked down https://github.com/rust-lang/cargo/pull/8421/files#r485577035 feel free to close if appropriate. |
It is possible to move this to the cargo repo but I do not have the required permissions. IMO this issue reflects a reasonable request, so I'd keep it open for now. I'd probably change the title; I would not even expect |
I personally am less certain that this should be considered a bug without the rerun-if-env-changed, as most crates don't want to rebuild when moving their directory around. Indeed, e.g., perf.rust-lang.org relies on that currently... |
IMO the least surprising behaviour is triggering a rebuild if the value returned by any
I'm envisaging this would only happen if said crate had |
Cargo does explicilty not rebuild a crate when it's folder is renamed, but it's true that the compilation would otherwise differ due to environment variables like this. What we can do, however, is Cargo can avoid recompiling on a directry name if this env var isn't used, but it would recompile if it was used. I think that would keep everything working generally as expected for other users which currently rely on this behavior not recompiling. |
I've just been faced with this problem. I think the issue should be named more clearly as "Build script isn't rebuilt if CARGO_MANIFEST_DIR compile-time variable changes, i.e. the source dir was moved". This bug reproduces in my build script that depends on a crate that uses |
In #12403 and #12482 we make it clear that the current behavior of It remains open to whether those env vars should trigger a rebuild, or we could treat |
CARGO_MANIFEST_DIR
changing doesn't trigger a rebuild, even ifrerun-if-env-changed=CARGO_MANIFEST_DIR
is specified in thebuild.rs
.Thus
env!("CARGO_MANIFEST_DIR")
andenv::var("CARGO_MANIFEST_DIR").unwrap()
can differ in binaries executed bycargo run/test/bench
.The text was updated successfully, but these errors were encountered: