[Hard drive insufficient space warning.] Time to free the gigabytes again.
$ for dir in $(find -name "target"); do (cd $dir/.. && cargo clean); done
Sound off. I got 110 gigabytes back. #rustlang
[Hard drive insufficient space warning.] Time to free the gigabytes again.
$ for dir in $(find -name "target"); do (cd $dir/.. && cargo clean); done
Sound off. I got 110 gigabytes back. #rustlang
I recommend the `cargo-clean-all` package, to do this easily without flakey shell scripting. It will automatically detect rust project directories and clean them.
There is also `cargo-sweep`, which is more flexible and can delete stuff selectively, rather than deleting the whole target directory. It can keep the build artifacts of your currently installed compiler version, as well as docs, so that you don't have to do clean builds when you go to work on your projects again, but delete files from older compiler versions, which still frees up a lot of disk space (especially if you use rust nightly).
Also, if you are on Linux, highly recommend using a filesystem like btrfs or bcachefs with compression. These filesystems are seriously efficient. They can pack tiny files to not waste disk space allocations and compression is very effective on rust target dirs.
On Windows and macOS, I constantly run out of disk space because of Rust, even though my partitions are hundreds of GBs.
On Linux with btrfs+compression, I never have. I do the cleanup occasionally, just for housekeeping, but i have never *had* to do it, and my Linux partition is much smaller, less than 100GB.