-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Configurable directory for temp files that isn't the target dir #6227
Comments
Yes please. I'm currently trying to figure out how to prevent my backup system from backing up 10GB of "useless" build artifacts, which still including the repository and possibly useful final builds. |
My use case is related to AI antivirus & antimalware - software has to be built in a special directory, otherwise sometimes binaries are sent to quarantine and the whole build killed. This especially affects |
I was able to work around this by specifying |
@spoelstraethan when setting CARGO_TARGET_DIR like this (so that it's shared), built executables/libs may use unexpected code, see #12516 |
Does #6790 remove the need for this? |
Currently
CARGO_TARGET_DIR
is a mix of two distinct functionalities:I'm finding that it's useful for me to have these two directories separate, as I treat temporary and non-temporary files differently.
Use-cases:
Working on NFS
I'm using Cargo in a virtual machine to work on a Linux-only project. But I'm a Mac user, so my project is on a network drive in the VM (vagrant), so that I can edit files easily from the host machine.
It's convenient to have built executables in the easily-accessible
./target
. OTOH the network drive is very slow, flaky, doesn't support hard links, and it makes rebuilds sloooow, so having intermediate build files in./target
is painful.Easy cleanup of temp files
Temp dirs in the target directory can be huge — a few GB large. I have an SSD which is almost full, so I can't afford having a few GB of temp files just laying here and there all over the disk, and I have to regularly go and delete the
target
directories in all projects I'm working on. The problem is that I have my Rust projects intentionally in various folders, so to delete the temp files I have to look for them in several places.I'd rather set a single system-global temp directory such as
/var/tmp/cargo/%some_hash_of_project/
(#6210) which is easy to delete (and on macOS it could be in the proper~/Library/Caches
).Integration with Xcode
Xcode already has distinction between "intermediate" files and "products". From Xcode's perspective
CARGO_TARGET_DIR
conflates the two, so it doesn't map well to Xcode's configuration. For cargo-xcode I had to add workaround for this.I think it could be solved by supporting a variable like
CARGO_TEMP_DIR
that would configure cargo to place the./target/<profile>/{build,native,.fingerprint,incremental}
directories somewhere insideCARGO_TEMP_DIR
.The text was updated successfully, but these errors were encountered: