Live data from Hacker News

Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

aruljohn.com

41–50 of 109 posts

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#41

We might also ask, why doesn't Linux also track such meta-data? Are Linux users not also subject to drive-by downloads impersonating valid files? Should we be one chmod a+x away from compromise?

Should I be able to run files I download on my own computer? I think yes I should, hate fighting MacOS to do simple tasks because Apple engineers assume the end user has the average intelligence of an ostrich.

That might be an overly optimistic assumption for the typical user, to be fair.

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#42
post #20

Earlier quoted context omitted.

> Arguably, principle of least surprise is very Apple. Principle of least surprise is good engineering practice. The question is always whose surprise. Someone who expects tar to behave like other UNIX systems is going to be surprised by this. Someone who expects tar on Apple to have perfect fidelity would be surprised by not-this. I increasingly feel like build systems should never be relying on any "native" utiliti…

Nixos has a pretty solid solution to this issue: key your dependencies with checksums of the content. That way you get the best of both worlds: you always get the exact version you want, and you can share a copy of that exact version with other software that wants to use that exact version too!

So it sounds like you don’t get the exact version you want because metadata is thrown away.

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#43
post #3

Earlier quoted context omitted.

Arguably, principle of least surprise is very Apple. If I point "tape archive" at a file system, I want that file system archived to tape. And so, tar does. If I don't, well, that's a fine option, and there's a fine option for that. So it's less of a "workaround" or something that "gets worse", than, "No, I don't really want a tape archive of this filesystem, only of some of it." And that's supported. That said, neve…

> Arguably, principle of least surprise is very Apple. Principle of least surprise is good engineering practice. The question is always whose surprise. Someone who expects tar to behave like other UNIX systems is going to be surprised by this. Someone who expects tar on Apple to have perfect fidelity would be surprised by not-this. I increasingly feel like build systems should never be relying on any "native" utiliti…

Apple is always surprised that non-Apple devices exist.

See: the permanent undismissable red icon to "finish setting up your Apple TV with your iPhone"

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#45
post #3

Ex-Apple engineer here. This is, for better or worse, just the way Apple approaches this type of problem. From Apple's perspective, this is the way to preserve Finder / Gatekeeper / metadata semantics. It avoids silent data loss when round-tripping archives between Macs. This behavior also maintains consistency with copyfile(3) (as well as the Archive Utility behavior). Apple treats tar less like “portable Unix inter…

Arguably, principle of least surprise is very Apple. If I point "tape archive" at a file system, I want that file system archived to tape. And so, tar does. If I don't, well, that's a fine option, and there's a fine option for that. So it's less of a "workaround" or something that "gets worse", than, "No, I don't really want a tape archive of this filesystem, only of some of it." And that's supported. That said, neve…

If you think that most people who run the tar command are assuming it will work like a tape archive, you'll probably be the one surprised

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#46
Would this ever affect me if I don't use many of MacOS built on tools? I brew install gnu equivalents make them all default. Just like how I also don't use most of their desktop environment stuff, and instead use rectangle, hammerspoon, karabiner to make it feel more like the Linux desktop I wish I could use at work.

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#47

Earlier quoted context omitted.

> Arguably, principle of least surprise is very Apple. Principle of least surprise is good engineering practice. The question is always whose surprise. Someone who expects tar to behave like other UNIX systems is going to be surprised by this. Someone who expects tar on Apple to have perfect fidelity would be surprised by not-this. I increasingly feel like build systems should never be relying on any "native" utiliti…

> The question is always whose surprise. I think that the surprise of more data than expected is more desirable than the surprise of data loss. So in this case, it seems like the safe choice.

Agreed. I usually hate on Apple, and its terribly ancient utilities and gratuitous incompatibility with modern Linux utilities, motivated by hatred of the GPL license.

But in this case, I think what it's doing is… basically fine? "Tar should faithfully reproduce the semantics of the source filesystem" is a perfectly reasonable starting point.

Ideally there would be a documented way to turn off the Apple-specific metadata with Apple's own tar, though.

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#48

Per this 2018 page, GNU tar seems to work with SCHILY.* encoded xattrs, but not LIBARCHIVE.* ones: * https://mgorny.pl/articles/portability-of-tar-features.html#... * Via: https://github.com/mxmlnkn/ratarmount/issues/145 bsdtar ≥3.7.2 apparently adds both types to its files for maximum portability: * https://github.com/libarchive/libarchive/pull/691/files#diff... AFAICT, bsdtar will default to "ustar" format, but wil…

I wonder how come GNU tar never added them. I have to assume someone has brought the problem to their attention before.

Re: Tar Files Created on macOS Display Errors When Extracting on Linux (2024)

#49
post #20

Earlier quoted context omitted.

Nixos has a pretty solid solution to this issue: key your dependencies with checksums of the content. That way you get the best of both worlds: you always get the exact version you want, and you can share a copy of that exact version with other software that wants to use that exact version too!

Are the xattr / chattr / umask checksums rolled into the main data fork content or are they hashed separately (or not at all)?

IIRC Nix is checksummed in the hash of the source of the content, not the results.
Post reply on HN