Skip to content

ci: change tar command on macOS runners #540

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

williamboman
Copy link
Contributor

@williamboman williamboman commented Apr 22, 2025

There seems to be some weird behaviour going on when creating compressed
tarballs with bsdtar this way (redirecting stdout). The produced files
seems OK, but gzip itself struggles to decompress it without errors,
resulting in a "trailing garbage ignored" error message and exit code 2
(it still decompresses the file just fine though). This error doesn't
surface when decompressing using bsdtar directly, but it does when
using gnutar.

See mason-org/mason-registry#9775.

If you have a Mac you should be able to reproduce this assuming tar -> bsdtar and that you have gnutar installed as gtar.

 $ echo Hello > file
 $ tar -cvz file > archive.tar.gz
 $ gzip -d -c archive.tar.gz > /dev/null
 # exit code 2 and gzip: archive.tar.gz: trailing garbage ignored

 # Method 1: Create tarball first and then gzip
 $ tar -cv file > archive.tar
 $ gzip archive.tar
 $ gzip -d -c archive.tar.gz > /dev/null
 # works fine!

 # Method 2: Create compressed tarball with the -f flag
 $ tar -czf archive.tar.gz file
 $ gzip -d -c archive.tar.gz > /dev/null
 # works fine!

I figured I'd open a PR since I found this somewhat interesting and
spent some time debugging it. Not entirely sure I've even found the root
cause but I believe this should help.

On my system this is the hexdump difference: https://www.diffchecker.com/z7Xqcfu8/. Right side is redirecting stdout, left side is using -f.

There seems to be some weird behaviour going on when creating compressed
tarballs with `bsdtar` this way (redirecting stdout). The produced files
seems OK, but `gzip` itself struggles to decompress it without errors,
resulting in a "trailing garbage ignored" error message and exit code 2
(it still decompresses the file just fine though). This error doesn't
surface when decompressing using `bsdtar` directly, but it does when
using `gnutar`.

See mason-org/mason-registry#9775.

If you have a Mac you should be able to reproduce this assuming `tar ->
bsdtar` and that you have `gnutar` installed as `gtar`.

```sh
 $ echo Hello > file
 $ tar -cvz file > archive.tar.gz
 $ gzip -d -c archive.tar.gz > /dev/null
 # exit code 2 and gzip: archive.tar.gz: trailing garbage ignored

 # Method 1: Create tarball first and then gzip
 $ tar -cv file > archive.tar
 $ gzip archive.tar
 $ gzip -d -c archive.tar.gz > /dev/null
 # works fine!

 # Method 2: Create compressed tarball with the -f flag
 $ tar -czf archive.tar.gz file
 $ gzip -d -c archive.tar.gz > /dev/null
 # works fine!
```
@tjex
Copy link
Member

tjex commented Apr 28, 2025

Really appreciate this! Very considerate and out of the blue :)

Will also take the opportunity to extend a big thank you for Mason 🙏

@tjex tjex merged commit a8b273f into zk-org:main Apr 28, 2025
3 checks passed
@williamboman
Copy link
Contributor Author

Thanks! Would it be possible to get a new patch release with new assets? There's some problems installing zk on Mac at the moment via Mason

@tjex
Copy link
Member

tjex commented Apr 29, 2025

williamboman added a commit to mason-org/mason-registry that referenced this pull request Apr 29, 2025
This should now be resolved via zk-org/zk#540.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants