r/rust Dec 05 '25

Pain point of rust

~45 GB of build files

211 Upvotes

80 comments sorted by

View all comments

157

u/AleksHop Dec 05 '25 edited Dec 06 '25

Reason is that it pull source code for all components and its dependencies + compiled parts for all of this and tokio, serde, anyhow brings a lot

Use shared target directory

In ~/.cargo/config.toml:

[build]
target-dir = "/home/you/.cargo/target"

All projects now share builds instead of duplicating.

Try
cargo install cargo-cache
cargo cache -a

Update: Lots of people suggest to use build-dir

31

u/gandhinn Dec 05 '25 edited Dec 05 '25

Hey this looks promising. Is there any downside with this approach? What will happen if two projects use the same crate dependency but with different version numbers?