Tar files made in macOS generate "xattr" errors when expanded in Linux

· ai · Source ↗

TLDR

  • macOS bsdtar embeds Apple xattrs and ._ resource fork files in tarballs, causing errors and warnings on Linux extraction.

Key Takeaways

  • BSD tar on macOS adds ._ prefixed files and extended headers like LIBARCHIVE.xattr.com.apple.quarantine to tarballs by default.
  • Quickest fix: add --no-xattrs or --disable-copyfile flags when creating the tar on macOS.
  • Permanent fix: install gnu-tar via Homebrew and prepend its path (/opt/homebrew/opt/gnu-tar/libexec/gnubin) in ~/.bash_profile.
  • Apple Silicon path differs from Intel: /opt/homebrew/... vs /usr/local/opt/....

Hacker News Comment Review

  • Commenters note suppressing warnings without fixing the root cause is viable: --warning=no-unknown-keyword or redirecting stderr to /dev/null works for extraction side.
  • An ex-Apple engineer framed this as intentional design: bsdtar preserves Finder, Gatekeeper, and copyfile(3) semantics to avoid silent metadata loss when round-tripping archives between Macs.
  • Consensus leans toward --no-xattrs --no-mac-metadata at creation time as the cleanest cross-platform deploy pattern.

Notable Comments

  • @pier25: recommends tar --no-xattrs --no-mac-metadata -czf as a deploy-ready default, adding --no-mac-metadata beyond what the article covers.

Original | Discuss on HN