-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Cargo should not use rustc cache results (.rustc_info.json) for failures #15358
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
Comments
While root cause is different, the caching of failures was previously discussed in #14385. It sounds like in this case, the concern is in specifically dealing with errors in developing a custom rustc / rustc wrapper and not regular development operations. While frustrating, I have a feeling that use case is small enough / rare enough that it wouldn't outweigh the benefits of the caching for all other use cases. The idea of reporting the caching to stdout was also mentioned but that could end up being quite noisy for a detail that doesn't matter to most people when we already want to be shrinking the amount of output we generate. |
Thanks for the link. First, I would note that rustc wrappers are explicitly supported by Cargo. Second, I would note that you now have multiple bug reports from different forms of cache-on-failure causing problems. Now to respond from some linked comments: In #14385, there's:
And in #9112, there's (from @alexcrichton ):
Debugging mystery errors that defy logic is not pleasant. You already ran into an issue, did the obvious thing to fix it, and there's no indication as to why it isn't working. Also:
This I don't understand. Can this be further explained? Finally, on outputting (cached):
It would be a minor thing to append that I think would at least be appropriate for verbose, where the commands being run are given. I'd be willing to cook up a patch and show the output as a proposal. |
Oh, I missed this
So it's purely from internal tests. As a priority, I would think drive-you-crazy bugs by users are more important than a hammer to squash a fly in the ointment of Rust's internal testing. Could this not be made an explicit option, to use in that case? |
Sorry if I seem like I'm talking to myself or piling on, but I'm still digging and note this is your take from #14385: epage on Aug 19, 2024
I agree with that guy. Whatever happened to him? How did it become "While frustrating, I have a feeling that use case is small enough / rare enough that it wouldn't outweigh the benefits of the caching for all other use cases.", and "all other use cases" is internal testing? I will keep digging and see if I can modify the tests so that they behave properly without exposing users to cache-on-failure. |
I have proposed a fix. What I did was keep the caching of failures, but if a failure is found, the cache result will not be used. Instead, the command is run again:
To deal with the
it will not find an update that occurred because a command failed:
I tested with
and I verified |
Problem
So I was setting up a customized rustc, stepping outside the bounds of rustup toolchains, and I got an error invoking rustc when running Cargo. I fix the error, then re-run, and immediately get the same error. I run strace to see if I can spot the problem, and I see the error message printed, but no system call to run rustc. I was going crazy!
I finally traced this to
src/cargo/util/rustc.rs::cached_output()
:After I removed the .rustc_info.json cache file, my cargo invocation worked. So long story short, considering that command caches are imperfect, it should not cache failures, to give the user the best chance of fixing the problem.
I also think if a cached result is used, it should append a (cached) to the standard output, because the cache is imperfect, and this might be a vital clue if something is not being rebuilt when the user expects it to be.
Steps
No response
Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: