5

Is it possible to make apt update flush information/re-download information?

apt update does not suggest any additional arguments when tab-tabbing in the CLI and returns with E: The update command takes no arguments when adding garbage to see what happens.

Also, Debian's apt man-page did not provide any helpful clues: https://manpages.debian.org/buster/apt/apt.8.en.html

I made it work with the following steps, which seems like a bit of a workaround:

1: move away /etc/apt/sources.list.d/*.list files

2: run apt update; this appears to flush the cache of repositories that is no longer found in a .list file

3: move back /etc/apt/sources.list.d/*.list files

4: run apt update again; with this, information is downloaded from the repositories

Is there any way to do this without juggling .list files?

tompi
  • 232
  • 3
  • 9

1 Answers1

9

Yes, you can clear apt’s index by deleting all the files in /var/lib/apt/lists:

sudo rm /var/lib/apt/lists/*_*

(all index files have underscores in their names, none of the directories in /var/lib/apt/lists do).

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • I will try this out as soon as I get a chance. Can you say anything additional as to whether this approach is recommended by the creators of apt - with a link to further information if possible? Or is it more of a homegrown solution? – tompi Mar 28 '20 at 14:58
  • 1
    Can confirm that this works as expected for my case. I did a bit more digging in the apt documentation and the closest I found to a mention of something similar to what is need was in the feature wishlist, and was apparently not very well received: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=873689 – tompi Mar 30 '20 at 13:42
  • Yes, I dug through the docs and couldn’t find anything... – Stephen Kitt Mar 30 '20 at 13:44
  • If you are running apt upgrade and get 404 errors, this fix also works to solve that problem. – Chris C. Jun 16 '23 at 16:58