-
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
Cargo's temp files cause backup churn on macOS #3884
Comments
Sounds like a nifty idea to me! |
What do you think about promoting this issue as beginner-friendly ? |
For me the question is how to call ObjC method from Cargo. There are various approaches for this. Does Cargo have some crate/macro/.m files for this already? If not, any preference? |
Perhaps the objc crate could be of assistance? |
I've managed to implement marking using the objc crate: https://gitlab.com/kornelski/exclude_from_backups/blob/master/src/macos.rs Are you OK adding it as a dependency, or should I copy the code to Cargo? |
Either's fine by me, although I'd slightly lean towards just copying it into Cargo as it may change over time. Thanks @pornel! Out of curiosity, have you confirmed that this does indeed fix the problem? |
I've verified that it sets The feature requires macOS 10.8+, so I'll need to disable it on 10.7. Does Rust's CI run on 10.7? I don't have a 10.7 machine to test on. |
Does this also solve the backup churn you were noticing? Also yeah we'll need to work on 10.7 somehow, but it's ok to not add a test for this. Is it possible to just ignore errors on 10.7? |
It may fail to link on 10.7. I'd have to use |
I've verified that it prevents the backup churn (I've manually marked all target dirs, and none were in my latest backup). |
I've also got a new implementation using servo/core-foundation-rs, which makes the code shorter. |
Ok looks and sounds great to me! |
Exclude target directory from Time Machine Fixes #3884
This patch follows the lead of rust-lang#4386 (which excludes target directories from Time Machine backups) and is motived by the same reasons listen in rust-lang#3884. CACHEDIR.TAG is an OS-independent mechanism supported by Borg, restic, GNU Tar and other backup/archiving solutions. See https://bford.info/cachedir/ for more information about the specification. This has been discussed in Rust Internals earlier this year[1] and it seems like it's an uncontroversial improvement so I went ahead with the patch. [1] https://internals.rust-lang.org/t/pre-rfc-put-cachedir-tag-into-target/12262/11
Exclude the target directory from backups using CACHEDIR.TAG This patch follows the lead of #4386 (which excludes target directories from Time Machine backups) and is motived by the same reasons listen in #3884. CACHEDIR.TAG is an OS-independent mechanism supported by Borg, restic, GNU Tar and other backup/archiving solutions. See https://bford.info/cachedir/ for more information about the specification. This has been discussed in Rust Internals earlier this year[1] and it seems like it's an uncontroversial improvement so I went ahead with the patch. One thing I'm wondering is whether this should maybe cover the whole main target directory (right now it applies to `target/debug`, `target/release` etc. but not to target root). [1] https://internals.rust-lang.org/t/pre-rfc-put-cachedir-tag-into-target/12262/11
macOS automatically makes hourly backups. Cargo's build temp files are large and frequently changing, causing gigabytes of redundant data backed up every day.
Because the temp files are in multiple project-relative locations, it's not practical for users to manually exclude all the target folders from backup.
Mac applications generally avoid this problem by using system-designed caches directory, but the issue for it (#1615) seems to be in a stalemate.
So I'm proposing an alternative quick fix that doesn't require changing any paths in Cargo. macOS allows excluding individual directories from backups. I suggest marking
target/{build,deps,incremental}
as excluded. It can be done with:The text was updated successfully, but these errors were encountered: