Skip to content

Cargo check should not block cargo run #15396

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

Closed
ConradIrwin opened this issue Apr 4, 2025 · 3 comments
Closed

Cargo check should not block cargo run #15396

ConradIrwin opened this issue Apr 4, 2025 · 3 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@ConradIrwin
Copy link

Problem

I work at Zed and we are heavy users of cargo check, primarily through rust-analyzer.

One problem that we have as a relatively large rust project is that cargo check and cargo run can take a while. We have other ideas to help with this (e.g. rust-lang/compiler-team#790), but it is our reality today.

This causes the common flow of wanting to run my changes after making them to be slower than I think they should be. This is because when I save a file, rust-analyzer starts a cargo check in the background, so by the time I switch to a terminal to type cargo run, it almost always is "Blocking waiting for file lock on build directory" for a long time.

As a (somewhat impatient) user, I would love if my build that I just kicked off happened immediately.

Proposed Solution

I don't know what the lock is protecting, so I can see a few different options here:

  • Reduce the granularity of locking to the crate level or module level so that both cargo run and cargo build could run co-operatively.
  • Add a mechanism to "prioritize" cargo processes; so a user-kicked-off build would pause the background cargo run while it was running.

Notes

It is possible today to avoid this locking by pointing cargo check to a different target directory when run by rust analyzer.

This works, but has the unfortunate side-effect of using more disk space (Even without this workaround, I have to run cargo clean about once a week because my target directory grows to several hundred gigabytes in that time, which causes builds to get slower still...), and seems to make the overall process slower (I guess there are some shared artifacts that cargo check and cargo build re-use from each other).

@ConradIrwin ConradIrwin added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Apr 4, 2025
@P1n3appl3
Copy link
Contributor

P1n3appl3 commented Apr 4, 2025

Related issue on rust-analyzer: rust-lang/rust-analyzer#18515
... and on cargo: #3501
... and on rust: rust-lang/rust#65427

@epage
Copy link
Contributor

epage commented Apr 9, 2025

#4282 is our issue for changing the locking scheme.

I'm going to close in favor of that issue. If there is a reason for us to keep this specific issue open, let us know!

@epage epage closed this as completed Apr 9, 2025
@ConradIrwin
Copy link
Author

Thanks! And sorry for missing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants