Knowledge Base:Remove orphaned packages

From Gentoo Wiki
Jump to: navigation, search

Synopsis

During regular system maintenance jobs, software packages will be pulled in as dependencies of other packages. When the other packages are removed from the system, these dependencies will remain and become orphaned packages. It is recommended to remove orphaned packages so that no unnecessary space is used. This action should be taken for security reasons because orphaned packages are not updated during regular @system or @world update sessions.

Environment

Any Gentoo Linux environment.

Analysis

When a user installs software, the software title itself is registered in the user's world file. During the installation, the necessary dependencies are also 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 since it is 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(s)) Gentoo's Portage supports a --depclean option. This option will scan the installed software and all dependency trees, identify the orphaned packages, and remove them.

Resolution

First, make sure that the system is up to date and that no open installation jobs are pending.

root #emerge -uDN @world

Then, invoke emerge --depclean --ask to remove orphaned packages (it will ask for confirmation):

root #emerge --depclean -a

To test if any obsolete packages are still found found on the system use the eix utility which comes with the following useful command:

root #eix-test-obsolete
Note
The eix utility can be obtained on a system by emerging the app-portage/eix package.

See also