-
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
"cargo check" (incorrectly) shows compiler errors that are not present when running "cargo build" #9971
Comments
In target/debug/.fingerprint there are many directories. But of note, there are:
I backed up my (apparently buggy) target directory, but then began deleting some of these directories in .fingerprint. I think deleting common-22eb78fa992cde90, common-af40c81771bb33e7, and common-d542ff3ffb485b8a had no effect. Deleting the others resolved the issue. I've attached the directories, in case they contain some useful information. Could these directories contain some timestamp information? I dual-boot with Linux, and whenever returning to Windows my system time has a multi-hour offset. |
Sorry you're running into that. Unfortunately without the full original target, we probably can't know exactly what is happening.
Yea, that is frustrating, I run into the same problem when dual booting and have never found a solution. This is almost certainly the cause, though. Cargo works with filesystem mtime timestamps. If it gets into a scenario where the timestamp for a fingerprint is in the future, it won't try to recompile something, or if the timestamp for the altered file ended up being far into the past. If you forgot to resync the clock (which I often do) and ran cargo just once (maybe rust-analyzer triggered a build when it started), then the timestamps can get out of whack. If you run into it again, you can set the There are two mtime comparisons:
The log messages will tell you the mtime values of all these things. You can then compare those mtimes with what you think should be valid. For example, if the dep-info mtime is in the future, or maybe a source file looks to be much older than expected. One thought I had while writing this is that cargo could check for timestamps that are far in the future compared to the system clock. This can be a little tricky because the timestamps on network filesystems can be set by the server which may not be in sync with the client, but I think cargo has problems with that anyway. |
It's a bit tricky that both past and future timestamps can cause issues. This seems to be a common issue for build systems. There are plenty of stackoverflow questions about make's "clock skew detected" warning, after all. Perhaps cargo could display some kind of warning too? This article (despite having a pretty opinionated title!) seems to have some reasonable suggestions: https://apenwarr.ca/log/20181113 Next time I run into the issue I'll collect a trace. |
We hope to move in the direction suggested in that article when we have a content hash system that works (cc #8623) |
Yea, relying on just mtime is known to be limiting in some cases. I'm going to close as a duplicate of #6529. If you are able to reproduce in such a way that doesn't involve mtime issues, feel free to reopen. |
Years later, this still seems to be an issue. I'm having a very similar problem with a similar setup. A crate with a few libs and inter-dependencies and for some reason, I kept getting an error in my ide (neovim) about a function not existing, but it does exist and the code compiles and executes cleanly otherwise. While it's in this state, I copied the directory to another and attempted to zip it but it's too large to share (19GB! I'm assuming, because of dependencies - it's really not a huge program). I tried running It's quite annoying as I can't trust what It may be worth noting that I'm using macos, and that this project's files are sitting on an external APFS volume that I use to switch back and forth between two macos-based machines... although I'm almost certain I've come across this issue before on projects that were on an internal SSD. Some output to demonstrate. These two commands were run back-to-back: reaper/eat_chili/surreal_digestive on main [$?] is 📦 v0.1.0 via 🦀 v1.69.0
❯ cargo check
Checking surreal_digestive v0.1.0 (/Volumes/2TB/reaper/eat_chili/surreal_digestive)
error[E0599]: no method named `new_determinate` found for mutable reference `&'life2 mut ProgressProvider` in the current scope
--> src/lib.rs:124:36
|
124 | let issues_step = progress.new_determinate(num_issues as u64);
| ^^^^^^^^^^^^^^^ help: there is a method with a similar name: `new_indeterminate`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `surreal_digestive` due to previous error
reaper/eat_chili/surreal_digestive on main [$?] is 📦 v0.1.0 via 🦀 v1.69.0
❯ cargo build
Compiling futures-sink v0.3.28
Compiling futures-channel v0.3.28
Compiling progress_provider v0.1.0 (/Volumes/2TB/reaper/eat_chili/progress_provider)
Compiling flume v0.10.14
Compiling sqlx-core v0.6.3
Compiling futures-util v0.3.28
Compiling futures-executor v0.3.28
Compiling tokio-tungstenite v0.18.0
Compiling futures v0.3.28
Compiling surrealdb v1.0.0-beta.9+20230402
Compiling sqlx-macros v0.6.3
Compiling sqlx v0.6.3
Compiling chili_provider v0.1.0 (/Volumes/2TB/reaper/eat_chili/chili_provider)
Compiling surreal_digestive v0.1.0 (/Volumes/2TB/reaper/eat_chili/surreal_digestive)
Finished dev [unoptimized + debuginfo] target(s) in 14.16s
reaper/eat_chili/surreal_digestive on main [$?] is 📦 v0.1.0 via 🦀 v1.69.0 took 14s
❯ |
In my case, |
you are my life saver! |
Unfortunately, |
Problem
I have a workspace of several crates. Two such crates are "common" (a library crate) and "game_lib", another library that depends on "common".
"common" contains several functions that are pass-by-value that were once pass-by-reference.
However, when I run
cargo c
in game_lib, I'm going getting errors that suggest that the compiler is seeing the old function signature. These errors occur in multiple places in game_lib, not just the example below. They occur for multiple functions inside common too, not justgeometry::rotate_point_about_origin
.Running
cargo b
, there is no such false error. rust-analyzer does not see the false error. When I made this change a few days ago, I'm pretty sure I would have runcargo c
multiple times, and did not see the error then.I've encountered this issue a couple of other times in the past. It pops up maybe once every couple of weeks. Running
cargo clean
always seems to resolve the issue, but I haven't done so yet in case there's valuable information that may be gleamed.Steps
cargo c
and see a compiler error.Possible Solution(s)
This feels like some kind of caching issue. Could cargo be caching some of the intermediate data used by
cargo c
?Notes
Output of
cargo version --verbose
:rustc 1.55.0 (c8dfcfe04 2021-09-06)
Windows 10
Output of
rustup show
:The text was updated successfully, but these errors were encountered: