rust-lang / rust-lang/cargo

Using git for change detection causes issue when moving/renaming files

Open
#9,986 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-rebuild-detection C-bug S-needs-info
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Problem

Whilst working in a workspace, I copied a Rust package to another folder. Upon running cargo build, it would do nothing, with no error, but 100% CPU usage.

When using RUST_LOG=trace CARGO_LOG=trace cargo build I saw many failed to get mtime of... messages.

Only until I made a VCS commit, did things start working again.

Unfortunately I did not record the logs before the fix so I will have to try and repro it again.

I did notice a line like this though:

[2021-10-20T13:36:50Z WARN  cargo::sources::path] list_files_git my-package v0.1.0 (/xxx/my-package)

Which made me think it was git related.

So something to do with list_files_git and fingerprinting causes issues. I think relying on git for any kind of change detection will cause issues.

https://github.com/rust-lang/cargo/blob/b74705419e39b206b326ce1e6187ad7c383dcb0e/src/cargo/sources/path.rs#L175

https://github.com/rust-lang/cargo/blob/b74705419e39b206b326ce1e6187ad7c383dcb0e/src/cargo/sources/path.rs#L91-L107

I will look to do a repro when I have time.

Steps

No response

Possible Solution(s)

Workaround is to commit your files. Or specify include should disable this functionality.

Notes

No response

Version
cargo version --verbose
cargo 1.54.0 (5ae8d74b3 2021-06-22)
release: 1.54.0
commit-hash: 5ae8d74b3b2d58f32c8d357e5cfa04d430a70e0b
commit-date: 2021-06-22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/cargo/sources/path.rs, especially list_files_git and the linked fingerprinting-related lines. Reproduce the issue by copying a Rust package and moving or renaming files, then run cargo build with tracing enabled. Done means the build completes without hanging, excessive CPU use, or failed mtime messages without requiring a VCS commit.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.