-
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
Spurious rebuilds of paths-overrides #2041
Comments
With some output from the newer cargo fingerprinting stuff: |
|
To recap, my belief is that this is the following bug:
There's a few possible solutions to this that I can think of:
The question of overriding a dependency with a whole new set of transitive dependencies has always been a little sketchy to me, so it's unclear how robust this can be made in the long-term. @larsbergstrom for now I'd recommend not using path overrides for large scale refactors but instead using normal git and path dependencies which should always be reliable. |
I'm having a lot of success right now just removing the I'm not really sure what you mean by |
Ah yeah I meant editing Cargo.toml to point to the new dependency (in a first class, not overridden fashion). But if that's too painful then ah well, worth a shot! |
Hi ! |
@cyplo Yes, but we can now use |
Cargo has a long-standing [bug] in path overrides where they will cause spurious rebuilds of crates in the crate graph. This can be very difficult to diagnose and be incredibly frustrating as well. Unfortunately, though, it's behavior that fundamentally can't be fixed in Cargo. The crux of the problem happens when a `path` replacement changes something about the list of dependencies of the crate that it's replacing. This alteration to the list of dependencies *cannot be tracked by Cargo* as the lock file was previously emitted. In the best case this ends up causing random recompiles. In the worst case it cause infinite registry updates that always result in recompiles. A solution to this intention, changing the dependency graph of an overridden dependency, was [implemented] with the `[replace]` feature in Cargo awhile back. With that in mind, this commit implements a *warning* whenever a bad dependency replacement is detected. The message here is pretty wordy, but it's intended to convey that you should switch to using `[replace]` for a more robust impelmentation, and it can also give security to anyone using `path` overrides that if they get past this warning everything should work as intended. [bug]: rust-lang#2041 [implemented]: http://doc.crates.io/specifying-dependencies.html#overriding-dependencies Closes rust-lang#2041
Warn about path overrides that won't work Cargo has a long-standing [bug] in path overrides where they will cause spurious rebuilds of crates in the crate graph. This can be very difficult to diagnose and be incredibly frustrating as well. Unfortunately, though, it's behavior that fundamentally can't be fixed in Cargo. The crux of the problem happens when a `path` replacement changes something about the list of dependencies of the crate that it's replacing. This alteration to the list of dependencies *cannot be tracked by Cargo* as the lock file was previously emitted. In the best case this ends up causing random recompiles. In the worst case it cause infinite registry updates that always result in recompiles. A solution to this intention, changing the dependency graph of an overridden dependency, was [implemented] with the `[replace]` feature in Cargo awhile back. With that in mind, this commit implements a *warning* whenever a bad dependency replacement is detected. The message here is pretty wordy, but it's intended to convey that you should switch to using `[replace]` for a more robust impelmentation, and it can also give security to anyone using `path` overrides that if they get past this warning everything should work as intended. [bug]: #2041 [implemented]: http://doc.crates.io/specifying-dependencies.html#overriding-dependencies Closes #2041
Another case #3136 has exposed that wasn't handled correctly before: If you've got a |
I think I've noticed something related to Servo's "spurious rebuilds" issue! They seem to be triggered by Cargo deciding that one of the
paths
-overrided dependencies needs to be rebuilt. So, we see it a LOT when working on a rustup (or things like my android changes touching a lot of stuff), but still see it a bit on Servo itself because we have apaths
override even in our default build (https://github.com/servo/servo/blob/master/components/servo/.cargo/config#L1 ).Basically, without touching my machine I can just re-reun a build and it will seemingly randomly occasionally have a "good rebuild" log, but much more often have a "bad rebuild" log. The bad ones always start with things that are being overridden - in this case, I'm overriding skia, angle, gleam, rust-offscreen-rendering-context, and glutin.
Fingerprint log of a good rebuild:
https://drive.google.com/file/d/0B9-EBhw4XiWEZlVRZUpGcjFqYVU/view?usp=sharing
Fingerprint log of a bad rebuild:
https://drive.google.com/file/d/0B9-EBhw4XiWEWU1TRGFaZVJfR2s/view?usp=sharing
Hope this is enough info to debug it!
The text was updated successfully, but these errors were encountered: