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

aruljohn.com

111 points by heresie-dabord 4 days ago


LatencyKills - 4 days ago

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 interchange” and more like “archive this filesystem object faithfully.” That is very Apple, and very libarchive. ;-)

This is probably going to get worse (as Apple continues to add macOS-specific metadata), so your workaround is very helpful.

I haven't tested it in a while, but at one point, setting the COPYFILE_DISABLE=1 env variable would disable the inclusion of macOS-specific metadata.

mxmlnkn - an hour ago

The title seems misleading.

These are not errors. They are simply warnings about extended attributes being ignored when extracting files, which seems completely fine to me, and creating the tar without those extended attributes has exactly the same outcome, but throws away the metadata at archive time instead of extraction time.

Furthermore, this is not an Apple/macOS issue. The tool used is bsdtar, so it would also affect all BSD-variants that default to bsdtar/libarchive, and those systems also have extended attributes, e.g., for SELinux, which would get added to the TAR.

pier25 - 11 hours ago

I use these settings when creating a tar file for deploy:

    tar --no-xattrs --no-mac-metadata -czf
throw0101a - 10 hours ago

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 will auto-switch to "pax" if needed.

nottorp - 2 hours ago

I don't see errors, just warnings about unknown metadata. It's annoying yes. But they aren't errors.

seba_dos1 - 6 hours ago

> Why does it have those extra files?

> For some reason

Very informative!

albertzeyer - 3 hours ago

But these are not errors. These are just warnings you can ignore? It's not really so critical?

red_admiral - 3 hours ago

Why switch to a completely different tar and rewire the PATH when you could just set a shell alias? You'll need to edit .bashrc both times but there's no need to install a second tar to /opt to solve this.

mg794613 - 25 minutes ago

Oh Arul John, just because you don't understand, means it's a error.

What horrible advice also to download different tar versions, for something that should just be explained properly.

If it weren't for the "2024" in the title, I would have thought this to be a result from AI.

But it's not artificial intelligence. It's real stupidity.

kaiwn - 23 minutes ago

Let me google the name of the author of this blog...

Oh...

angry_octet - 11 hours ago

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?

chmaynard - 10 hours ago

Homebrew installs GNU tar as "gtar". On my M4 MacBook:

  $ which gtar
  gtar is /opt/homebrew/bin/gtar
raffraffraff - 6 hours ago

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.

bombcar - 9 hours ago

I'll admit that if I don't care about extended attributes (I never really do) I just use zip instead.

firesteelrain - 11 hours ago

You can either send stderr to /dev/null or use --warning=no-unknown-keyword to suppress them cleanly.

But still interesting nonetheless why they are added

LoganDark - 2 hours ago

> If you are using a Mac with an Apple Silicon M1, M2, M3 or M4 processor,

Don't forget the MacBook Neo's A18 Pro :)

anthk - 5 hours ago

How well does pax handle this?