Knowledge Base:Remove orphaned packages

Synopsys
During regular system maintenance jobs, software packages are being pulled in as dependencies of other packages. When the other packages are removed from the system, these dependencies remain and become orphaned packages. It is recommended to remove these so that no unnecessary space is used, but also for security considerations as orphaned packages are not updated during regular system/world update sessions.

Environment
Any Gentoo Linux environment.

Analysis
When a user installs software, the software title itself is registered in the users' world file. During the installation, the necessary dependencies are also being pulled in and installed. These packages however are not registered in the world file.

When software is removed from the system, its entry in the world file (if applicable) is removed as well. The dependencies of that software however remain on the system as it is well possible that the dependencies are also used by other (installed) software titles.

To support clean-up of orphaned packages (software packages that are not in the dependency tree of any installed software title) Gentoo's portage supports the depclean operation that scans the installed software and all dependency trees, identifies the orphaned packages and removes them.

Resolution
First, make sure that your entire system is up to date and that no open installation jobs are still pending.

Then, invoke emerge --depclean -p to see what the depclean operation would remove, and then emerge --depclean to remove them.