/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
echo '<html>404 Not Found</html>' > download.tar
tar -xf download.tarOutput · 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
echo '<html>404 Not Found</html>' > download.tar
file download.tar
head -c 40 download.tarOutput
download.tar: HTML document, ASCII text <html>404 Not Found</html>
A real archive gives a different answer:
mkdir src && echo hello > src/a.txt
tar -czf good.tar.gz src
file good.tar.gz | cut -d, -f1
tar -tf good.tar.gzOutput
good.tar.gz: gzip compressed data src/ src/a.txt
file says | What to do |
|---|---|
| HTML or ASCII text | Bad download; fetch again with curl -fL |
| Zip archive data | unzip file |
| gzip compressed data | tar -xf file (or gunzip) |
| empty | Interrupted 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
Related pages
errors · targzip: stdin: not in gzip format / tar: Child returned status 1tar -xzf fails with gzip: stdin: not in gzip format when the file is not gzip: a plain tar, an xz or zstd archive, or an HTML page. Check it with file, drop -z.commands · tartar -xzf: extract a .tar.gz archiveExtract a .tar.gz archive with tar -xzf archive.tar.gz. Use -C to choose the target directory, -t to list contents first and -v to print each extracted file.errors · tartar: Removing leading `/' from member namesGNU tar prints Removing leading / from member names when archiving an absolute path. The archive is fine; use -C to store relative paths, or -P to keep them.