-
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
Mark temporary directories as excluded from macOS Spotlight #8686
Conversation
r? @ehuss (rust_highfive has picked a reviewer for you, use r? to override) |
We've historically had friction trying to rename build directories due to how baked in the current structure is to other external tools, but is there perhaps a way to exclude items from spotlight with file attributes rather than by filename? (something like what we do for time machine for example) |
Yeah, having to use the name for this seems painful. Might be preferable to put it in one of the standard macOS directories that get excluded, or putting it somewhere in the |
Another possibility: if there's any concern that something might be looking in these directories, we could use |
@alexcrichton AFAIK there's no filesystem attribute for this. |
Symlinks sound like an easy way out. How about taking it further and symlinking to |
This doesn't affect old installation on macOS, right ? |
It's true that a possible alternative is to place everything in the system default location, but Cargo isn't necessarily the best prepared for that. One thing I think we'd need to handle is Overall this is unfortunately a tricky problem in that renaming build directories is ripe for breakage. When we discussed this the idea of symlinks seemed like they could possibly fix the issue, though, so I think it might be worthwhile to explore what a solution might look like where caches are placed in more system-friendly directories (e.g. |
Or well there's also always the gotcha that symlinks are difficult/different on Windows. I think we can get away with "directory junctions" regardless of user preferences, which may work for our purposes as well, but we'd have to investigate. |
Thank you for the input. Here's the plan:
|
On Mon, Sep 14, 2020 at 07:35:39PM -0700, Kornel wrote:
Thank you for the input. Here's the plan:
* I'll make existing target folders keep everything as-is (real directories) to improve back compat and ease migration.
When you upgrade Rust, you're already going to rebuild everything and
you can't do an incremental build, so replacing the build and incremental
directories seems perfectly fine.
* New target/ directories will have symlinks to a subdirectory in system's temp *if* it's on the same device. Otherwise keeps existing behavior.
Only for build and incremental, right?
Also, if the system's temp directory is not on the same device, how
about using adjacent `build.noindex` and `incremental.noindex`
directories as the symlink targets?
* To keep this change small, the the subdirectory in temp will be unique per workspace to avoid adding new form of sharing of build artifacts (these dirs could be unified later)
You mentioned using a hash, but please also prefix it with a crate name
or similar, for future troubleshooting, so that it's possible to figure
out roughly where it came from.
|
That sounds about right I believe yeah. A possible further simplification, though, is that We'll still want to test this though since |
|
I think |
☔ The latest upstream changes (presumably #8739) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
@@ -170,6 +172,7 @@ impl Layout { | |||
fingerprint: dest.join(".fingerprint"), | |||
examples: dest.join("examples"), | |||
doc: root.join("doc"), | |||
temp_root: Self::temp_root_path(&root), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is a bit confusing, because cache and temp are usually different things and people people have different conceptions about them.
if path.exists() { | ||
return Some(path.join("cargo")); | ||
} | ||
None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand this logic – is there any reason why it ignores the "important" part of XDG and instead does something completely different altogether in the "env not set" case?
More generally, reimplementing the directory-selection logic seems to be a straight-forward route to bikeshed city (as demonstrated in the RFC).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What "important" part do you mean?
I am afraid that touching XDG is going to attract bikeshed fiesta. I'm tempted to remove it for that reason, and go straight for /var/tmp
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What "important" part do you mean?
XDG defines default directories if the env var is not set. The env var is probably not set in 99% of the cases, because people are fine with the defaults.
Only "being XDG" when the env var is set ... if I wanted to troll people, that's how I would do it. ;-)
I am afraid that touching XDG is going to attract bikeshed fiesta.
Did you consider simply using a library?
I'm tempted to remove it for that reason, and go straight for /var/tmp instead.
That's a cheap way out for this special case, but I'm not sure you want the next person following this precedent when they try to fix the issue for config/data files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've considered using a library, but it this area is full of abandoned projects and half-abandoned forks, so I didn't see any suitable crate.
I think the best option would be to use a cargo-specific variable/setting for customizing this dir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've considered using a library, but it this area is full of abandoned projects and half-abandoned forks, so I didn't see any suitable crate.
I think no crate can help you if your intention is to invent your own non-standard scheme anyway.
I think the best option would be to use a cargo-specific variable/setting for customizing this dir.
That's of course technically possible, but is does nothing to resolve rust-lang/rfcs#1615 which is about sane defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think no crate can help you if your intention is to invent your own non-standard scheme anyway.
Jabs like that are unhelpful. Please don't do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a nice day.
#8684
macOS doesn't support
CACHEDIR.TAG
, and Cargo doesn't use correct temporary dir locations for macOS. As a workaround, directories can be excluded from macOS Spotlight indexing by adding.noindex
suffix.I've added the suffix only to
build
andincremental
. Ideally.fingerprint
anddeps
should have it too, butdeps
appears in user-visible paths and.fingerprint
seems to be an experimental public API, so I haven't changed these two.This may be better served by #8063