APT Autoremove – Why ‘apt-get autoremove’ Did Not Work Properly

aptsoftware installationxubuntu

I installed Pipelight from the PPA archive, according to these instructions.

The installation command, sudo apt-get install --install-recommends pipelight-multi was for only one package, but it entailed downloading and installing about 180 dependency packages, about 40 of which were upgrades to currently-installed packages.

Therefore, about 140 new packages were installed.

Pipelight subsequently didn't work, so I removed it:

sudo apt-get purge pipelight-multi

No other packages were removed.

I then used sudo apt-get autoremove. This command removed all auto-removeable packages. There were exactly 100 of these (there were also exactly 100 packages in Synaptic Package Manager's 'Autoremovable' list).

So this left about 40 packages that weren't considered auto-removeable, and so weren't removed. I had to remove them manually.

There were no unmet dependencies on my system before I installed Pipelight; and I hadn't marked any packages as manually-installed, installed or removed anything else, or anything like that. Only about ten minutes passed between installing Pipelight and removing it.

So after I removed Pipelight, why weren't all of its unneeded dependencies marked as auto-removable?

Best Answer

My best guess is that the 40 packages were recommended by other packages you had already installed; pipelight-multi along with the --install-recommends option caused them to be installed, but they were kept after its removal because of those recommendations. Since you've removed the packages manually it's hard to determine, but in future you can run aptitude why ${package} for each package you think should be auto-removed, and aptitude will tell you why it's being kept.

The mechanics behind this aren't necessarily intuitive. When a package is flagged as auto-removable, either manually or automatically (in the latter case, because it's installed automatically to satisfy a dependency or recommendation), the auto-removal flag is the only information stored; the system doesn't remember why a package was automatically installed. Such packages are kept only as long as some other package depends on them, or recommends them (this is the default setting, it can be changed).

All this would explain your situation as follows. You already have some other package, A, installed; this package recommends B but the latter isn't installed. You install pipelight-multi which also recommends B; given that you explicitly specified --install-recommends, we know B is then installed along with pipelight-multi. When you remove pipelight-multi and run apt-get autoremove, B is marked as auto-removable and gets checked, but because A is still installed, B is kept, even though the package which caused it to be installed in the first place is gone. Because A only recommends B, you can manually remove B to get back to the initial situation.