7 comments

  • LatencyKills3 days ago
    Ex-Apple engineer here. This is, for better or worse, just the way Apple approaches this type of problem. From Apple&#x27;s perspective, this is the way to preserve Finder &#x2F; Gatekeeper &#x2F; 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).<p>Apple treats tar less like “portable Unix interchange” and more like “archive this filesystem object faithfully.” That is very Apple, and very libarchive. ;-)<p>This is probably going to get worse (as Apple continues to add macOS-specific metadata), so your workaround is very helpful.<p>I haven&#x27;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.
    • Terretta1 day ago
      Arguably, principle of least surprise is very Apple.<p>If I point &quot;tape archive&quot; at a file system, I want that file system archived to tape. And so, tar does.<p>If I don&#x27;t, well, that&#x27;s a fine option, and there&#x27;s a fine option for that.<p>So it&#x27;s less of a &quot;workaround&quot; or something that &quot;gets worse&quot;, than, &quot;No, I don&#x27;t really want a tape archive of this filesystem, only of some of it.&quot; And that&#x27;s supported.<p>That said, <i>never</i> seeing another .DS_Store should be a system-wide option!
      • JoshTriplett2 hours ago
        &gt; Arguably, principle of least surprise is very Apple.<p>Principle of least surprise is good engineering practice. The question is always <i>whose</i> 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.<p>I increasingly feel like build systems should never be relying on any &quot;native&quot; utilities from the host system, and should instead be bringing them in via dependencies. You can&#x27;t have this problem if your packaging system pulls in a specific portable `tar` library.
        • Joker_vD53 minutes ago
          &gt; I increasingly feel like build systems should never be relying on any &quot;native&quot; utilities from the host system, and should instead be bringing them in via dependencies.<p>Well, you see, while this, frankly, applies not just to build systems but to most of software, the consensus in the community of distro-maintainers is that it&#x27;s actually wrong: you should use your system&#x27;s package manager, and tools it can install, and let it fiddle with the ambient environment and give you that delicious &quot;path dependency&quot;. And if your distro&#x27;s packaging environment doesn&#x27;t allow to do the things you need (e.g. being able to install both mongodb 3.8 and mongodb 5.0, ideally at the same time, but okay, I can keep running apt remove&#x2F;install over and over, but I do need to check if my app correctly handled the wire protocol changes), well, that&#x27;s your problem for desiring strange things.
        • amarant1 hour ago
          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!
          • JoshTriplett1 hour ago
            Yeah, Nix-like distributions (e.g. guix, lix) do for Linux systems what some language package managers (e.g. cargo) do for individual projects.
      • taftster2 hours ago
        &gt; That said, never seeing another .DS_Store should be a system-wide option!<p>Yes please.
        • ryandrake2 hours ago
          .DS_Store, .fseventsd, .Spotlight-V100, .Trashes, and ._this and ._that<p>These can all die in a fire too, as far as I am concerned. macOS loves to treat the user&#x27;s filesystem as its own personal garbage dump.
          • gerdesj1 hour ago
            thumbs.db and those weird MS alternative stream files for recording origination.<p>filesystem attributes are for decorating files with meaning. Anything else that attempts to use filesystems in &quot;interesting&quot; ways is silly.<p>Apple and MS really ought to consider why they do this sort of fragile, idiosyncratic nonsense.
            • Joker_vD1 hour ago
              But... thumbs.db is precisely <i>not</i> an &quot;attempt to use filesystems in &quot;interesting&quot; ways&quot; — it&#x27;s literally a just hidden file with previews stored in it. Storing the preview in the alternative stream of the file with the picture itself would be &quot;an interesting way&quot;.
              • kstrauser1 hour ago
                Agreed. Where else would you put that stuff? It’s gotta go somewhere, and this is the least surprising place IMO. Anywhere else would have to be a parallel store that follows filesystem mounts and unmounts, renaming directories, etc so that it alway perfectly mirrors the thing it’s configuring.
          • emmelaich1 hour ago
            OTOH, If you want the information contained in those files, where else would you save it?
            • ajxs13 minutes ago
              To me it seems more sensible to store <i>information relevant only to this OS</i> in a specific cache somewhere within that OS. It would even make cache-like functionality such as evicting old entries super easy.
    • matheusmoreira2 hours ago
      It&#x27;s a good attitude to have, in my opinion. Portability is overrated. Linux developers should be doing a lot more of this. We should be making everything work better for us without caring how it&#x27;s going to impact other irrelevant platforms. Let the people who actually care about those platforms worry about such things.
      • cozzyd2 hours ago
        It would at least be nice if there was a way to keep apple users from shitting all over the filesystem with remote mounts and ds_store files. Perhaps by automatically unmounting if one is detected.
        • bombcar53 minutes ago
          At least if you&#x27;re using ZFS as the backing store and Samba, you can set <i>vfs objects = catia fruit streams_xattr</i> and similar config options to use extended attributes.
    • jmclnx2 hours ago
      To me, the big question is why Apple needs all these file attribute ? If the files are extracted OK, just ignore the errors :)
      • bombcar52 minutes ago
        Apple has had multiple streams per file since the very beginning, and it can store useful and necessary information (the latter is quite rare now, as most things have sane defaults, but losing the extended attributes can lose things that can be annoying).
  • pier252 hours ago
    I use these settings when creating a tar file for deploy:<p><pre><code> tar --no-xattrs --no-mac-metadata -czf</code></pre>
    • jherskovic55 minutes ago
      I do this same thing too when building archives in macOS I will unpack on Linux later.
  • throw0101a1 hour ago
    Per this 2018 page, GNU tar seems to work with SCHILY.* encoded xattrs, but not LIBARCHIVE.* ones:<p>* <a href="https:&#x2F;&#x2F;mgorny.pl&#x2F;articles&#x2F;portability-of-tar-features.html#generic-extended-attributes" rel="nofollow">https:&#x2F;&#x2F;mgorny.pl&#x2F;articles&#x2F;portability-of-tar-features.html#...</a><p>* Via: <a href="https:&#x2F;&#x2F;github.com&#x2F;mxmlnkn&#x2F;ratarmount&#x2F;issues&#x2F;145" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mxmlnkn&#x2F;ratarmount&#x2F;issues&#x2F;145</a><p>bsdtar ≥3.7.2 apparently adds both types to its files for maximum portability:<p>* <a href="https:&#x2F;&#x2F;github.com&#x2F;libarchive&#x2F;libarchive&#x2F;pull&#x2F;691&#x2F;files#diff-dadc66d540d1d3dbe2364cc4e7c99e329b68e6830e467e594002f03864074231R146" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;libarchive&#x2F;libarchive&#x2F;pull&#x2F;691&#x2F;files#diff...</a><p>AFAICT, bsdtar will default to &quot;ustar&quot; format, but will auto-switch to &quot;pax&quot; if needed.
  • angry_octet2 hours ago
    We might also ask, why doesn&#x27;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?
    • danielheath2 hours ago
      Yes, we should be.<p>My computer should run programs when I tell it to run them.<p>Don’t blunt _every_ tool just to make them harder to cut yourself on.
      • rtpg37 minutes ago
        Increased metadata isn&#x27;t tool blunting in itself though, even if MacOS uses it for being... annoying is one way of saying it.<p>Provenance information bundled into a file is not the worst idea in the world IMO. We have created&#x2F;modified timestamps on files already, right? There&#x27;s definitely the question of &quot;why&quot; but hey if more of my binaries just had at least a tag about who put them there that would be a win in my book.<p>Not an argument for doing what MacOS does, just an argument that the info would be nice to have.
      • angry_octet1 hour ago
        I hope you&#x27;re in the very small minority of people who rigorously manage untrusted downloads and whitelist every binary, because you&#x27;re operating an appliance from the 1970s, sticking a metal fork into an un-earthed toaster. Most people need help from their operating system.
      • Joker_vD1 hour ago
        I sincerely agree. By the way, thanks for lending your machine for my &quot;Network-Retransmission-and-Compute-as-a-service&quot; network.
    • emmelaich1 hour ago
      Tar on linux will. e.g. selinux attrs and other xattrs.<p>Open question, is it worth attempting to main these semantics between mac and linux.
    • bitfilped1 hour ago
      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.
  • bombcar51 minutes ago
    I&#x27;ll admit that if I don&#x27;t care about extended attributes (I never really do) I just use <i>zip</i> instead.
  • chmaynard2 hours ago
    Homebrew installs GNU tar as &quot;gtar&quot;. On my M4 MacBook:<p><pre><code> $ which gtar gtar is &#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;gtar</code></pre>
    • fastily53 minutes ago
      Ive installed the gtar formula and aliased it to tar. Cant be bothered to memorize the differences between macOS tar and unix tar, especially when the latter is considered to be the de facto standard
  • firesteelrain2 hours ago
    You can either send stderr to &#x2F;dev&#x2F;null or use --warning=no-unknown-keyword to suppress them cleanly.<p>But still interesting nonetheless why they are added