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
fetchFromGitHub inconsistent hash #39308
Comments
Maybe diff those paths? I would guess it's to do something with case-insensitivity or Unicode normalization on MacOS. |
Yeah, we've seen problems like this before because of filename normalisation. |
eg. #26280 (comment) |
Yeah, Darling has a case overlap: https://github.com/darlinghq/darling/blob/master/src/libm/Source/Intel/xmmLibm_Prefix.h vs. https://github.com/darlinghq/darling/blob/master/src/libm/Source/Intel/xmmLibm_prefix.h The uppercase one is a symlink to the lowercase one. Just clone the repo on a Mac (or case-insensitive filesystem) and Git will instantly tell you there's an unstaged change, because while cloning it overwrites one file with the other. |
Very weird! It looks like Apple's libm has some typos causing that symlink to be necessary. |
Seems like a hypothetical darling Nix build could inject that symlink at build time on Linux rather than at fetch time on all platforms. So the fetcher removes it unconditionally, and then you have an Edit: the fetcher needs to be careful too, because when unpacking the file, it's not guaranteed (I think) which case gets unpacked first, so in some cases the symlink can overwrite the file and in other cases the file can overwrite the symlink. And of course, you can't just blindly remove the overlapping file in Someday we can assume APFS across the board and then just stick the Nix store and build staging areas on a case-sensitive mount. |
I've opened darlinghq/darling#379 for this. Although it would be nice if we could figure out how to normalize it within Nix. @copumpkin I wonder if it would be useful to have Nix just remove the case conflicts automatically. This could break some things but even Linux users will occasionally have to work on case insensitive file systems. From what I see case sensitive files are fairly rare in Nix anyway. The current "hash" mismatch is at the very least a confusing error message. |
IIRC case conflicts are actually somewhat common, there are some in |
@matthewbauer the issue is that Nix never even sees the case conflict, unless I'm misunderstanding you. If you run
On Linux, that results in two files. On a case-insensitive (but preserving) filesystem, that produces a single file whose name is By the time Nix sees any of these directory trees to hash the fixed-output derivations, they just contain nonsense with no indication as to how they got that way, and a single hash isn't big enough (or structured enough) to preserve information on individual filenames or such to indicate that a case screwup occurred. The only way I can think of to catch it would be to monitor file creation and write events in child processes, which we could conceivably do inside Nix on macOS with Somewhat relatedly, @shlevy has done some work on this for Hackage, basically (as I remember it) figuring out how to optimally partition and extract a big tarball with case overlaps to multiple directories so they don't overlap on the target filesystem. This only works (without significant other patch-up work) if the end result doesn't need to coexist though, which isn't the case with darling and Linux because they have a bunch of |
So I was thinking of doing something like this for every fetchzip (which is what fetchFromGitHub uses):
Basically just get rid of any files that are case conflicts (realizing now that the above won't actually work, but something like it could). It's probably not worth doing because of how rare case conflicts actually are. |
@matthewbauer so you'd kill case conflicts on the Linux side? The kernel source tree uses nontrivial case overlaps extensively. |
Ah I did not realize that! It surprises me that that's the case. Anyway, probably best to deal with it in a case by case way. |
We should have a check that warns about this, I've just lost an hour or two on it. |
Problem
I've been struggling to get
fetchFromGitHub
to work correctly. It's from darlinghq/darling. Here is the expression:But, Hydra has reported it's incorrect (on a Darwin machine):
but then also reports this (on a Linux machine):
Jobs:
Attempted fixes
I've gone back and forth between the two with neither working 100% (probably due to cache sharing between Linux/Darwin machines).
85cadf9
9330ef4
6bb3ec8
I think it has something to do with symlinks in the GitHub repo. Maybe there is some impurity introduced by the filesystem?
The text was updated successfully, but these errors were encountered: