Apt-get problems

Hi, i've had this problem for quite a while now. But i've left it on the back burner. I get this error when trying to apt-get -f install

Failed to fetch http://archive.debian.org/debian-security/pool/updates/main/p/python2.7/python2.7-dev_2.7.3-6+deb7u4_armel.deb  Hash Sum mismatch
W: Unable to read /etc/apt/preferences.d/ - FileExists (2: No such file or directory)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Not sure what the problem is.

TIA.

Hello,

What this might mean is that the hashes for your local copy of the package file list don't match the hashes on the remote package file list, for some reason. Perhaps at one point an update got interrupted, or you got a partially-updated list of files, or something of that nature.

To fix it, I'd start with:

apt-get clean
apt-get update

and then see if the problem persists. If it does, then remove the files in the /var/lib/apt/lists/ directory, try the two above commands again, and then re-try your download once more.

Hope this helps ! If neither of these suggestions help let us know and we can take things from there.

1 Like

Does /etc/apt/preferences.d/ exist?
You create it with

sudo mkdir /etc/apt/preferences.d

or

sudo mkdir -p /etc/apt/preferences.d

to make sure (and not see any errors)

Make sure you're running it as root as well, it could be a permissions issue; but yes i would sudo mkdir -p /etc/apt/preferences.d/;sudo apt-get clean && sudo apt-get update && sudo apt-get -f install .

Definitely looks like the package exists--

$ links -dump 'http://archive.debian.org/debian-security/pool/updates/main/p/python2.7/' | grep -i 'python2.7-dev_2.7.3-6+deb7u4_armel.deb '
   [   ]       python2.7-dev_2.7.3-6+deb7u4_armel.deb         2017-11-24  27M 

Pretty sure an update will fix it.

Seems pretty clear what the error is, @ignatius , as other team members have correctly pointed out.

Normally, the error messages are very helpful and generally point to the root causes of errors.

This is a warning W and not an error E. /path/to/foo.d are drop-in folders that do not have to exist, as they are intended for local config files that are not touched by package updates (as long as they are not part of a package themselves, like /etc/apt/apt.conf.d/70debconf). In contrast to e.g. /etc/pkg.conf or /etc/default/pkg.

$ mv -v /etc/apt/preferences.d{,x} && apt-get -f install; echo $?
`/etc/apt/preferences.d' -> `/etc/apt/preferences.dx'
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory)
0

Hash Sum mismatch is the actual error, so try

# ignore `Is a directory` message
$ rm -f /var/lib/apt/lists/* && apt-get update && apt-get -f install

In addition, a) Python2 has been out of support since 2020 and b) Debian 7 since 2018, they should therefore no longer be used as they no longer receive security updates. And because of b), apt-get update usually prints a KEYEXPIRED warning.

Sorry for the late reply. But, thank you sir. That did the trick.

I saw you chose this post of yours as the solution. Shouldn't the solution be this instead?

1 Like

you can lead a horse to water, but you can't make it drink it ! :sunglasses: