The reason autoremove
isn’t removing as much as you expect is that the packages which were installed automatically satisfy weak dependencies of other packages you already had installed. In your case, dpkg-dev
is already installed, itself as an automatic dependency; because it recommends the virtual c-compiler
package, any package providing c-compiler
will be kept after it’s installed.
Put another way, you have package A already installed with a weak dependency on package B, and package B isn’t installed. If you later install package C, with a dependency (strong or weak, but taken into account by apt
’s configuration) on package B, package B will also be installed, and marked as automatically installed. Removing package C however won’t cause package B to be considered for auto-removal, because package A keeps it “interesting” as far as apt
is concerned.
You could ask autoremove
to ignore weak dependencies (recommendations, by default), but that would probably cause a lot more packages to become removable than you’d expect or want.
I’m not aware of any good solution for this. aptitude
is somewhat more agressive in its automatic removals, but it doesn’t handle all situations either.
See How do recommends and suggests interact with apt-get dist-upgrade and apt-get autoremove? and Why did 'apt-get autoremove' not work properly? for more on this.
aptitude why gcc-8
say? (I’m not trying to solve this particular instance, but I have a theory which I’d like to check before writing an answer.) – Stephen Kitt Oct 2 '19 at 16:00i g++-8 Depends gcc-8 (= 8.3.0-6ubuntu1~18.04.1)
. – philipp2100 Oct 3 '19 at 7:28i libxml2-dev Depends libicu-dev i A libicu-dev Depends libicu-le-hb-dev i A libicu-le-hb-dev Depends libharfbuzz-dev i A libharfbuzz-dev Depends libglib2.0-dev (>= 2.19.1) i A libglib2.0-dev Depends pkg-config i A pkg-config Depends dpkg-dev i A dpkg-dev Recommends gcc | c-compiler i A gcc-8 Provides c-compiler
– philipp2100 Oct 3 '19 at 7:32aptitude remove/purge
it works forg++-8
, but the problem still occurs forg++
. The output is the same as above, except with7
instead of8
. – philipp2100 Oct 3 '19 at 8:42