Skip to content
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

Provide cargo clean --except-locked to keep target/ small in re-used CI caches #12138

Closed
LeoniePhiline opened this issue May 13, 2023 · 1 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.

Comments

@LeoniePhiline
Copy link

LeoniePhiline commented May 13, 2023

Problem

When caching target/ in CI, the cache is uploaded and downloaded frequently and must remain manageable in size.

Whenever dependencies have been updated, e.g. by renovate-bot, new versions of crates are compiled and cached in target/deps/ while old versions are never removed.

cargo clean removes all build artifacts, including those of current dependencies - which is not desirable.

Proposed Solution

cargo clean --except-locked would inspect the Cargo.lock file of the project or workspace and keep all build artifacts of currently locked dependency versions. All other artifacts are deleted, as they would be with cargo clean.

Notes

Arguably cargo clean should exactly do that (clean up, not delete everything), while its current behavior can be easily done by hand with a rm -rf ./target.

I assume, however, that it is too late to change the default behavior at this point.

@LeoniePhiline LeoniePhiline 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 May 13, 2023
@ehuss
Copy link
Contributor

ehuss commented May 13, 2023

Thanks for the suggestion! We are currently tracking this in #7150. Cargo currently doesn't have a way of knowing which artifacts exist for which purpose. That issue contains some more information and links to similar issues.

Closing as a duplicate of #7150.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2023
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

2 participants