1

The following script

mkdir test && cd test
mkdir files
touch files/{1,2,3}
tar --create --file "test.lzma" files/{1,2,3} --auto-compress
mkdir extracted_files
tar --extract --file "test.lzma" --directory extracted_files --auto-compress

produces the following error:

tar: This does not look like a tar archive

but actually tar+compress and uncompress+untar do happen (files are in place). Why is this happening? Is it some kind of bug in tar?

On my system:

xz --version
 xz (XZ Utils) 5.2.7
 liblzma 5.2.7
tar --version
 tar (GNU tar) 1.34
file test/test.lzma
 test/test.lzma: LZMA compressed data, streamed
ls test/extracted_files/
 files

You can also reproduce it in https://replit.com/languages/bash (with xz (XZ Utils) 5.2.2 and tar (GNU tar) 1.34). But not in https://www.onlinegdb.com/online_bash_shell (with xz (XZ Utils) 5.2.4 and tar (GNU tar) 1.30).

1
  • I can't reproduce the issue in Ubuntu Windows Subsystem for Linux. For me your script works just fine and extracts the file without an error. When I run file test.lzma I get test.lzma: XZ compressed data (which is not what you got), so maybe that has something to do with the problem. I can reproduce the issue at replit.com/languages/bash though. Oct 21, 2022 at 15:23

1 Answer 1

0

Fixed in upstream. Check out https://savannah.gnu.org/bugs/index.php?63250.

@Sergey Poznyakoff <gray>:

The "This does not look like a tar archive" is not an error, but a warning. It is produced, in particular, when tar is unable to determine file format by signature and file size is less than tar block size. When the signature recognition fails, tar tries to determine file format by its suffix. In this case, it succeeded and extracted the files.

I have installed the following fix to recognized LZMA files produced by xz:

http://git.savannah.gnu.org/cgit/tar.git/commit/?id=02f9af1b8df67e55ceb19ea1465d210a2fa1f02c

PS: The --auto-compress option is not needed when extracting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .