TECH / Серверы и сайты 2 min read

Fixing “tar: Unrecognized archive format” on FreeBSD – Causes and Quick Fix

NEMCD Author
Published Feb 4, 2014 · 2 min

While updating software from ports or unpacking third-party archives on a FreeBSD server, you can occasionally hit the error tar: Unrecognized archive format, causing the build to abort right after downloading the archive.

FreeBSD logo – fixing tar Unrecognized archive format error

Almost every time, this comes down to one of two causes: either the downloaded file is corrupted (often an HTML 404/redirect error page saved as a tarball), or FreeBSD’s built-in bsdtar choked on an archive format or GNU-specific header that GNU tar (gtar) handles without complaint.

Step 1. Verify the Archive Is Not Corrupted First

Before changing tools, inspect the downloaded archive inside /usr/ports/distfiles/ with file:

file /usr/ports/distfiles/your_archive.tar.gz

If it reports HTML document, ASCII text, or empty, delete the broken file from /usr/ports/distfiles/, update your ports tree, and re-fetch it cleanly.

Step 2. If the Archive Is Valid, Switch to GNU tar (gtar)

When the tarball itself is intact – especially on older FreeBSD releases encountering newer compression formats or GNU tar extensions – installing gtar solves the issue right away.

The fastest route is installing the binary package:

pkg install gtar

Or building it directly from ports:

cd /usr/ports/archivers/gtar && make install clean

Next, point the ports framework to GNU tar by adding this line to /etc/make.conf:

TAR=/usr/local/bin/gtar

Finally, return to your failing port directory, clean the previous attempt, and build again:

make clean && make install clean

Once the port builds cleanly, you can either keep gtar enabled or comment out the line in /etc/make.conf to return to FreeBSD’s default bsdtar.

Related posts:

Leave a Comment