can't update software, how to fix this?

Asked by moh. rifqi adam

rifqi@rifqi-1215B:~$ ubuntu-support-status
Traceback (most recent call last):
  File "/usr/bin/ubuntu-support-status", line 122, in <module>
    with apt.Cache() as cache:
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 113, in __init__
    self.open(progress)
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 165, in open
    self._depcache = apt_pkg.DepCache(self._cache)
SystemError: E:The package apt needs to be reinstalled, but I can't find an archive for it.
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ cat /etc/dpkg/dpkg.cfg.d/multiarch
cat: /etc/dpkg/dpkg.cfg.d/multiarch: No such file or directory
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ dpkg --print-foreign-architectures
i386
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo grep -R roxy /etc/apt/*
[sudo] password for rifqi:
Sorry, try again.
[sudo] password for rifqi:
rifqi@rifqi-1215B:~$ ubuntu-support-status
Traceback (most recent call last):
  File "/usr/bin/ubuntu-support-status", line 122, in <module>
    with apt.Cache() as cache:
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 113, in __init__
    self.open(progress)
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 165, in open
    self._depcache = apt_pkg.DepCache(self._cache)
SystemError: E:The package apt needs to be reinstalled, but I can't find an archive for it.
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ cat /etc/dpkg/dpkg.cfg.d/multiarch
cat: /etc/dpkg/dpkg.cfg.d/multiarch: No such file or directory
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ dpkg --print-foreign-architectures
i386
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo grep -R roxy /etc/apt/*
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ grep roxy /etc/environment
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ echo $http_proxy

rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ echo $ftp_proxy

rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ grep roxy /etc/bash.bashrc
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ grep roxy ~/.bashrc
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ cat /etc/apt/apt.conf
cat: /etc/apt/apt.conf: No such file or directory
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo fuser -vvv /var/lib/dpkg/lock
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo fuser -vvv /var/cache/apt/archives/lock
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ uname -a
Linux rifqi-1215B 4.8.0-36-generic #36~16.04.1-Ubuntu SMP Sun Feb 5 09:39:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo rm /var/lib/apt/lists/lock
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo rm /var/cache/apt/archives/lock
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo rm /var/lib/dpkg/lock
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo cp -arf /var/lib/dpkg /var/lib/dpkg.backup
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo mv /var/lib/dpkg/status /var/lib/dpkg/status-bad
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status || sudo cp /var/backups/apt.extended_states.0 /var/lib/dpkg/status
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo mv /var/lib/dpkg/available /var/lib/dpkg/available-badmv: cannot stat '/var/lib/dpkg/available': No such file or directory
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/availablecp: cannot stat '/var/lib/dpkg/available-old': No such file or directory
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo rm -rf /var/lib/dpkg/updates/*
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo rm -rf /var/lib/apt/lists
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo rm /var/cache/apt/*.bin
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo mkdir /var/lib/apt/lists
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo mkdir /var/lib/apt/lists/partial
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ LANG=C;sudo apt-get clean
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ LANG=C;sudo apt-get autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo dpkg --configure -a
dpkg: error processing package apt (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 apt
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo dpkg --clear-avail
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ LANG=C;sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package apt needs to be reinstalled, but I can't find an archive for it.
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ LANG=C;sudo apt-get --fix-missing install
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package apt needs to be reinstalled, but I can't find an archive for it.
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ LANG=C;sudo apt-get --purge autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package apt needs to be reinstalled, but I can't find an archive for it.
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ LANG=C;sudo apt-get --fix-missing update -o APT::Cache-Limit=100000000
Reading package lists... Done
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ LANG=C;sudo apt-get update -o APT::Cache-Limit=100000000 && sudo apt-get dist-upgrade
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package apt needs to be reinstalled, but I can't find an archive for it.
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ find /etc/apt -name '*.list' -exec bash -c 'echo -e "\n$1\n"; cat -n "$1"' _ '{}' \;

/etc/apt/sources.list

     1 # deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
     2
     3 # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
     4 # newer versions of the distribution.
     5 # deb-src http://id.archive.ubuntu.com/ubuntu/ xenial main restricted
     6
     7 ## Major bug fix updates produced after the final release of the
     8 ## distribution.
     9 # deb-src http://id.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
    10
    11 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    12 ## team. Also, please note that software in universe WILL NOT receive any
    13 ## review or updates from the Ubuntu security team.
    14 # deb-src http://id.archive.ubuntu.com/ubuntu/ xenial universe
    15 # deb-src http://id.archive.ubuntu.com/ubuntu/ xenial-updates universe
    16
    17 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    18 ## team, and may not be under a free licence. Please satisfy yourself as to
    19 ## your rights to use the software. Also, please note that software in
    20 ## multiverse WILL NOT receive any review or updates from the Ubuntu
    21 ## security team.
    22 # deb-src http://id.archive.ubuntu.com/ubuntu/ xenial multiverse
    23 # deb-src http://id.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
    24
    25 ## N.B. software from this repository may not have been tested as
    26 ## extensively as that contained in the main release, although it includes
    27 ## newer versions of some applications which may provide useful features.
    28 ## Also, please note that software in backports WILL NOT receive any review
    29 ## or updates from the Ubuntu security team.
    30 # deb-src http://id.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
    31
    32 ## Uncomment the following two lines to add software from Canonical's
    33 ## 'partner' repository.
    34 ## This software is not part of Ubuntu, but is offered by Canonical and the
    35 ## respective vendors as a service to Ubuntu users.
    36 # deb http://archive.canonical.com/ubuntu xenial partner
    37 # deb-src http://archive.canonical.com/ubuntu xenial partner
    38
    39 # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
    40 # deb-src http://security.ubuntu.com/ubuntu xenial-security universe
    41 # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
rifqi@rifqi-1215B:~$
rifqi@rifqi-1215B:~$ sudo dpkg --audit
The following packages are in a mess due to serious problems during
installation. They must be reinstalled for them (and any packages
that depend on them) to function properly:
 apt commandline package manager

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

E: The package apt needs to be reinstalled, but I can't find an archive for it.

Is your issue

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

https://packages.ubuntu.com/xenial/apt

What is the output of:

apt-cache policy apt

Thanks

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

Please provide also the output of the commands

dpkg -l | grep ' apt'
ls -l /var/cache/apt/archives/apt_*

Revision history for this message
moh. rifqi adam (rifqiadam) said :
#4

The output of apt-cache policy command is
Apt:
        Installed: 1.2.20
        candidate: 1.2.20
        version table :
  ***1.2.20 100
             100 /var/lib/dpkg/status

Revision history for this message
moh. rifqi adam (rifqiadam) said :
#5

The output of dpkg -i | grep 'apt'
Dpkg-deb: Error: --info need a .deb filename argument

Revision history for this message
moh. rifqi adam (rifqiadam) said :
#6

Answer of the apt need to be reinstalled, but i can't find an archive for it.
Yes, it's my issue, how to fix that??

Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#7
Revision history for this message
Manfred Hampl (m-hampl) said :
#8

You mistyped the command, please provide the output of

dpkg -l | grep ' apt'
ls -l /var/cache/apt/archives/apt_*

(the option in the first command is a small L, not a small i)

Solution to your problem probably will be that you download the file
https://launchpad.net/ubuntu/+archive/primary/+files/apt_1.2.20_amd64.deb
to a suitable directory on your hard disk, open a terminal window, change directory (cd) to that directory where you have stored the file and then issue the command
sudo dpkg -i apt_1.2.20_amd64.deb

You have to be aware that the data in your /etc/apt/sources.list file are nonsense; you do not have any repositories enabled as potential source for your package management system. This does not make sense at all.

Can you help with this problem?

Provide an answer of your own, or ask moh. rifqi adam for more information if necessary.

To post a message you must log in.