-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 occasionally fails to detect changed source code files #8100
Comments
Do you have a reproducible set of steps we could investigate to try to figure out what's going on? |
I would be surprised if it is #2426, there is specific protection so that Cargo will detect if a file is modified during a build. Running with the |
On Mon, Apr 13, 2020 at 07:48:35AM -0700, Alex Crichton wrote:
Do you have a reproducible set of steps we could investigate to try to figure out what's going on?
I wish I did! Then I would have been able to make a much more thorough
bug report :(
|
On Mon, Apr 13, 2020 at 09:26:42AM -0700, Eric Huss wrote:
Running with the `CARGO_LOG=cargo::core::compiler::fingerprint=trace` environment variable will log some details about why cargo thinks something is out of date or not. Starting with beta (1.43), it logs additional information like the mtime it is detecting.
Thanks, I've noted this and will try it next time the issue appears.
|
On Mon, Apr 13, 2020 at 07:48:35AM -0700, Alex Crichton wrote:
Do you have a reproducible set of steps we could investigate to try to figure out what's going on?
If it's any help, these issues mostly crop up on a build server where
the source code files (e.g any recent changes) are synced to the server
with rsync. Then cargo (occasionally) fails to detect the updated files
until I do `cargo clean`.
|
If you are syncing with rsync, you have to be very careful with filesystem mtimes (such as dealing with the preserve-times feature). The two machines should have their time synced. Additionally, you should avoid this pattern:
|
On Mon, Apr 13, 2020 at 11:22:53AM -0700, Eric Huss wrote:
If you are syncing with rsync, you have to be very careful with filesystem mtimes (such as dealing with the preserve-times feature). The two machines should have their time synced. Additionally, you should avoid this pattern:
1. rsync -a
2. Modify source file
3. Build on server (from step 1)
4. rsync -a
5. Build on server (will not detect updates because build output from step 3 is newer than the changed source files from step 2).
The two machines' clocks are not locked together but they both get their
time from NTP and (checking now) right now the clocks are exactly synced.
The pattern referenced above does not apply. A common example would be:
1. `rsync --recursive --times --links --progress --chmod=ugo=rwX --checksum`
2. Build on server
3. Tests fail (on server)
4. Fix code locally
5. rsync as #1
6. Build on server
7. Tests fail again ("but I just fixed that")
|
This problem cropped again today. I tried prepending the above Sadly I am deep in a project so I will need to destroy my wonderful little test case by running |
Looks like the trick is to do:
before running anything else, just passing CARGO_LOG doesn't seem to do it. The issue has cropped up again despite running
|
Looks like my local machine's time had got out of sync with the server's. It's too early to say whether this is enough to resolve the problem. I've also removed the |
Now too many things are coming back as outdated: the Cargo logging data shows it's identifying as outdated files that I haven't changed. |
Making a small change, re-uploading, and running tests shows that everything works now. The fix was therefore either: |
Not sure if I should open a new issue for this, but I can still reproduce this with these steps using cargo 1.50.0 (f04e7fa 2021-02-04), rustc 1.50.0 (cb75ad5db 2021-02-10):
To clarify, what I end up with is a main.rs that looks like this: fn main() {
println!("Hello, world!");
} Which is the default main.rs that cargo builds for new projects, but Is this expected? |
Unfortunately, yes. Cargo only tracks mtimes, and the "orig" main has an mtime older than the last build. Using alternate change-tracking techniques such as content hashing is tracked in #6529. |
@ehuss Ok - I figured it was possibly a minor design flaw more than just a bug. I'm sure this isn't the place to discuss, but a combination of mtime/file_size, OR hashing, just like rsync does it, might be a good solution. Looks like devs are already working on it. Thanks for clearing that up. |
I encountered this bug today on:
Can't reproduce after I ran |
Normally when I run cargo
build
,test
, etc then any changes I've made to the code are picked up as expected & it re-compiles those parts of the binary.Occasionally it does not do so, and I need to run
cargo clean
, then recompile to have my changes recognised.This seems very similar to #2426 and would probably be solved by #6529
Meta
rustc --version --verbose
:Checking whether it happens in nightly isn't currently possible as it's an intermittent issue. I will have to remember to check the next time the issue appears.
The text was updated successfully, but these errors were encountered: