file: tar.gz mime-type returns as empty
Summary
The file command gets the mime-type of tar.gz archives wrong on alpine 3.18 and edge. This was not the case in 3.16. This is causing an issue for my project.
What happens
When using the following commands:
wget http://prdownloads.sourceforge.net/argtable/argtable2-13.tar.gz
file --no-sandbox --uncompress --mime-type argtable2-13.tar.gz
I see the following result with Alpine 3.18 and Edge:
argtable2-13.tar.gz: application/x-empty
In 3.16 it returns the following:
argtable2-13.tar.gz: application/x-tar
On Debian 12 and Archlinux, I see the same result as in Alpine 3.16, even though they use the same version of file as Edge and 3.18. This is what I would expect on all systems.
For some extra info, the --no-sandbox
option is required when using --uncompress
. I can reproduce this on at least 11 different tar.gz archives in this repo: https://github.com/pspdev/psp-packages
What might solve this
It seems there is a possible upstream patch here, but in my tests it did not resolve the issue.
The project linked is a community made and maintained homebrew SDK for the Playstation Portable. We use pacman to package our stuff, which uses file to determine what to do with archives under the hood when building package. The exact command it uses is file -S -bizL -- "argtable2-13.tar.gz"
, which also returns application/x-empty
as mime-type.
I hope this gives enough information to be able to debug this and possibly address this.