Skip to content

/errors/tar/this-does-not-look-like-a-tar-archive

tar: This does not look like a tar archive

verified onenvironmentlocal · linux 6.18.44-fc-v140 x64 · GNU bash 5.2.21 · tar (GNU tar) 1.35updated
tool
tar
exit code
2
versions
GNU tar 1.x
os
linux, macos

tar: This does not look like a tar archive means the file read by tar -x has no valid tar header. The file is not what its name says: an HTML error page, a truncated download or a different archive format. Inspect it with file before changing tar options.

Reproduce it

bash
echo '<html>404 Not Found</html>' > download.tar
tar -xf download.tar

Output · exit 2

tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

With GNU tar the first line is followed by tar: Exiting with failure status due to previous errors, and the exit status is 2.

Check what the file is

bash
echo '<html>404 Not Found</html>' > download.tar
file download.tar
head -c 40 download.tar

Output

download.tar: HTML document, ASCII text
<html>404 Not Found</html>

A real archive gives a different answer:

bash
mkdir src && echo hello > src/a.txt
tar -czf good.tar.gz src
file good.tar.gz | cut -d, -f1
tar -tf good.tar.gz

Output

good.tar.gz: gzip compressed data
src/
src/a.txt
file saysWhat to do
HTML or ASCII textBad download; fetch again with curl -fL
Zip archive dataunzip file
gzip compressed datatar -xf file (or gunzip)
emptyInterrupted download; fetch again

curl -f makes HTTP errors fail instead of saving the error page, and -L follows redirects. For .tar.gz problems with gzip see gzip: stdin: not in gzip format.

Sources