"tar: unrecognized option --warning" during 'apt-get install'
I've just had exactly this problem. As Gilles suggested, upgrading tar
is the answer but (surprise surprise) tar
can't be upgraded in the usual way because dpkg
requires version 1.23 or later before it'll unpack and install the latest tar
deb. dpkg
really needs an explicit dependency to ensure that when a later version of dpkg
is installed, the latest tar
version goes on first, but I guess it's a risk with combining different testing and unstable releases in unsupported ways. It's still undesirable and this seems an unfortunate way to cripple a system.
My first idea was to look for the latest binary of tar
at the GNU project, but unfortunately they only have source downloads, which aren't helpful if (like me) you don't have the various compiling tools installed.
If you download the latest tar
binary .deb
to match your system from packages.debian.org and drop it into a temporary place somewhere (just to be tidy), you should be able to get inside it with the ar
command, e.g. ar x tar_1.26-2_amd64.deb
in my case.
Then unpack the resulting data.tar.gz
file with a command like tar zxvf data.tar.gz
, using your existing earlier version of tar
, which should work as long as you don't try and do anything silly like use a --warning
parameter that won't be available until version 1.23. :) This will then let you get at the tar
binary, which (within the data.tar.gz file) was probably at bin/tar
.
Having done this, I added the path for that binary to the front the PATH
variable in my shell, which in my bash shell could be done with the command export PATH=/root/temp/bin:$PATH
, but adjust the path to fit wherever the new tar
binary is now sitting. After that, running a regular dpkg --install tar_1.26-2_amd64.deb
worked wonders, because dpkg
will look in the path and find the latest tar
binary before it finds the older version in the regular bin
path.
I didn't have ar
on my system, so I did this horrible kludge:
mv /bin/tar /bin/tar.real
echo "tar.real xpf -" >/bin/tar
chmod +x /bin/tar
cd /
# put in the correct path
dpkg-deb -x /var/cache/apt/archives/tar_1.26-4_armel.deb .
# check things are working and then
#rm /bin/tar.real
You may not need to worry about downloading the tar package.
Chances are, to get to this point because you were in the middle of an upgrade, and your package management system will have already downloaded the latest tar package for you, so it will be waiting for you in:
/var/cache/apt/archives/tar_(version-release_platform).deb
e.g.:
# ls -t /var/cache/apt/archives/tar_*|head -1
/var/cache/apt/archives/tar_1.26-4_amd64.deb
This is how I fixed my system:
Find the latest version on your system:
root@host:~# ls -t /var/cache/apt/archives/tar_*|head -1
/var/cache/apt/archives/tar_1.26-4_amd64.deb
Create a temporary working area and unpack the .deb archive:
root@host:~# mkdir fix_tar
root@host:~# cd fix_tar
root@host:~/fix_tar# ar x /var/cache/apt/archives/tar_1.26-4_amd64.deb
Unpack the data.tar.gz file to find the new tar binary:
root@host:~/fix_tar# ls -l
total 972
-rw-r--r-- 1 root root 2536 2012-02-03 12:20 control.tar.gz
-rw-r--r-- 1 root root 978996 2012-02-03 12:20 data.tar.gz
-rw-r--r-- 1 root root 4 2012-02-03 12:20 debian-binary
root@host:~/fix_tar# tar xzf data.tar.gz
root@host:~/fix_tar# find * -name tar
bin/tar
usr/share/doc/tar
usr/lib/mime/packages/tar
Check the existing version on your system:
root@host:~/fix_tar# /bin/tar --version
tar (GNU tar) 1.20
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
Backup the old version in case something goes horribly wrong and you need it back:
root@host:~/fix_tar# mv /bin/tar /bin/tar_1.20
Put the new copy in place:
root@host:~/fix_tar# mv ./bin/tar /bin/tar
Check the new version:
root@host:~/fix_tar# /bin/tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
You're done! :-)
I was then able to carry on with another:
root@host:~# aptitude update
root@host:~# aptitude safe-upgrade