Centralizing compilation artifact storage/cache for crates?

While learning Rust and developing something, I have numerous project folders, many of which share the same crates as I test out different ideas.

Some of these folders are easily ~500MB to ~2GB in size, taking up inordinate amounts of space, but containing many of the same compilation artifacts (presumably, as they have the same dependencies).

I see that the sources for crates are stored under ~/.cargo/registry/crates.

Is there no way, then, to centralize the compiled libraries for these crates as well under the same location? Why are those stored per project?

1 Like

You can set target-dir but it breaks some things apparently. There's no built in solution so far.

See:

2 Likes

That is interesting, thanks. Also quite an old Github issue! Reading through the comments, there are obviously a lot of complications and many aspects that need to be considered. It is not just a straightforward matter of keeping the compilation artifacts in one place.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.