-
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
Garbage collect whole target/
#13136
Comments
@rustbot claim |
Three ways for cargo clean script
|
To clarify, those are use cases for why tracking of whole I'd do a small tweak of wording in case this leads to confusion
|
It's for every target directory. |
Currently, we do the batch-save in cargo/src/cargo/core/package.rs Line 459 in c939267
cargo/src/cargo/core/package.rs Line 540 in c939267
which gets called as part of resolving: cargo/src/cargo/ops/resolve.rs Line 221 in c939267
which gets called as part of cargo/src/cargo/ops/cargo_compile/mod.rs Line 267 in c939267
So our options are
|
A code path to model off of is cargo/src/cargo/sources/git/source.rs Lines 147 to 157 in c939267
|
Problem
With "cargo script", the target directory is "hidden" from the user, making it easy to leak when you delete your script.
If we move forward with rust-lang/rfcs#3371, a similar situation will happen for regular packages.
If I haven't touched a project in a long while but have run
rustup update
, there might be nothing of use left intarget/
, wasting space.Sometimes I want to
cargo clean
all projects on my system (see #11305).Proposed Solution
We should track in the GC data base a list of
Cargo.toml
/ cargo script associated with the target directory)Cargo.lock
for future potential work like Pin cache entries still in use #13137 without having to infer theCargo.lock
(special logic needed for cargo-script, feature requests exist for even weirder situations)Note that neither of the two fields can serve as a unique / primary key. If people use
CARGO_TARGET_DIR=/tmp/cargo
then multiple workspaces may point to the same target dir. Likewise, people may end up with multiple target dirs for one workspace.We need to track the
Cargo.toml
/ cargo script because the workspace root is ambiguous when it comes to cargo scripts.Example entries for
CARGO_TARGET_DIR=/tmp/cargo
:Example entries for rust-analyzer target dir
Forms of cleanup
target/
if unused for X time (this is in the "locally recreatable" category)target/
(I just upgraded Rust, maybe rustup could suggest this)target/
(workspace doesn't exist)Notes
No response
The text was updated successfully, but these errors were encountered: