How Recommends and Suggests Interact with apt-get dist-upgrade and autoremove

apt

I'm trying to get my head round the "suggests" and "recommends" relationships between Debian packages. I know that they give the users more choice about what to install and what not to.

But I'm only aware of manual and auto markers to indicate the reason for a package being installed. This doesn't contain enough information to track user decisions on whether or not to install suggested and recommended packages. I can't see in the documentation what behaviour apt takes for (package X recommends Y and suggests Z):

apt-get dist-upgrade upgrading X to a newer version which no-longer recommends Y or suggests Z.

apt-get dist-upgrade upgrading X to a newer version which recommends and suggests new packages (not already installed).

apt-get autoremove removing package X.


Best Answer

“Recommends“ and “Suggests” relationships mostly have an effect on package installations, and sometimes removals, not on upgrades.

At installation time, depending on its configuration (APT::Install-Recommends and APT::Install-Suggests), apt will automatically install any packages which are recommended and/or suggested along with the package carrying the recommendation or suggestion. The default settings enable this for recommendations, not suggestions. Packages installed in this way are marked as automatically installed.

At removal time, removing a package will cause apt to remove packages depending on the removed package, but it won’t process recommendations or suggestions. apt autoremove will then look for any package which is marked as automatically installed, and which no longer has any depending package (including recommendations and/or suggestions, depending on the Apt::AutoRemove::RecommendsImportant and Apt::AutoRemove::SuggestsImportant settings); any such package will be removed. The default settings keep recommended and suggested packages (which is asymmetric compared to the installation defaults, but avoids surprises).

At upgrade time, only installed packages are considered. apt upgrade tries to upgrade all installed packages to their candidate versions, without removing any package. apt full-upgrade (or dist-upgrade) considers removing packages if it allows other packages to be upgraded, but it won’t remove a package just because it stops being recommended as a result of the upgrade. Packages which are newly recommended or suggested by an upgraded package aren’t installed automatically. Packages which are no longer recommended or suggested become candidates for the next autoremove.

aptitude behaves slightly differently; it will perform the equivalent of apt autoremove when removing packages, and it will tell you about newly-recommended packages (but it won’t select them for installation automatically).

The following questions provide complementary information:

Related Question