···11+---
22+title: "Pop quiz: what is wrong with this tar command?"
33+date: 2024-08-19
44+desc: "It's stupider than you think"
55+hero:
66+ ai: "Flux [dev]"
77+ file: laptop-anger
88+ prompt: "A green haired anime woman with green eyes and very long hair angrily typing on a laptop, headphones, seattle, space needle, black hoodie, best quality, coffee shop"
99+ social: true
1010+---
1111+1212+Pop quiz: what is wrong with this tar command?
1313+1414+```sh
1515+tar cf ../iosevka-iaso.tgz .
1616+```
1717+1818+<Conv name="Aoi" mood="wut">
1919+ That looks fine to me? You're creating a tarball in the parent directory with
2020+ the contents of the current working directory. What's the problem?
2121+</Conv>
2222+2323+```sh
2424+$ tar xzf iosevka-iaso.tgz
2525+gzip: not a compressed stream
2626+```
2727+2828+The thing I messed up was not adding `z` to the tarball creation command. I needed to do:
2929+3030+```sh
3131+tar czf ../iosevka-iaso.tgz .
3232+```
3333+3434+This happens because GNU tar looks at file extensions to try to determine the user's intent. If you do `tar xf foo.tgz` or `tar xf foo.tar.gz`, it will invoke gzip to decompress the tarball for you. This is intended behavior, but that same logic doesn't run when you create a tarball.
3535+3636+I lost 15 minutes to this today and feel that I need to let y'all know so you can learn from my suffering.