3

I've noted sometimes after apt install something deb files are left in /var/cache/apt/archives/ but sometimes they are gone right after installation.

I've read comprehensive explanation of install process in Ubuntu in Why are there deb files in /var/cache/apt/archives/? but there is nothing there on how/when deb files get deleted from cache, it says:

.deb package files remain cached in /var/cache/apt/archives even after successful installation in case they're needed for future use.

Web search gave no results to the specific question of my concern. Why sometimes deb files get deleted immediately after installation?

ADDED: Just before installing that something I manually deleted all previous debs from /var... maybe it mattered and the reason. Probably I should try to use apt clean (just read about it in https://www.cyberciti.biz/faq/can-i-delete-var-cache-apt-archives-for-ubuntu-debian-linux/) instead of manual rm.

ADDED 2: I've just tried to run apt clean before installing another package - empty /var after install again.

  • They do not in my close to couple of decades of running Debian based distributions it never has happened, any time I look like just now I see the large amount of files in there all with various dates they were downloaded and installed on. Many duplicates as the versions were updated included in those files seen. I see not one shred of evidence from you to show it has occurred on your machine. Only you saying it has, how have you determined it happens? –  Feb 13 '21 at 03:54
  • It has happened to my system as well (Ubuntu 20.04) on several occasions. – polarbear347 Apr 17 '21 at 10:11

1 Answers1

3

You have probably upgraded to a version of apt that does not keep installed packages by default, you can check by running:

apt-config dump | grep 'Keep-Downloaded-Packages'

and you will likely see:

Binary::apt::APT::Keep-Downloaded-Packages "0";

If that's the case then you can keep packages again by changing that setting to 1/true:

echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' | sudo tee /etc/apt/apt.conf.d/99-keep-downloads
Compholio
  • 376