# Removing orphaned packages



## GullibleJones (Nov 19, 2008)

What's the best way to remove orphaned packages on FreeBSD, i.e. dependencies of packages that have been uninstalled? I've tried pkg_rmleaves, pkg_cleanup, and pkg-orphan, but none of those three even detect orphaned packages properly. If, for instance, I install and uninstall porttools, that will leave sudo, ruby, and a bunch of other packages I don't need installed, of which pkg_rmleaves will only detect sudo.

Suppose a FreeBSD guru installs something huge, with lots of deps, and later he wants to remove it and all of its dependencies. How does he go about doing that?


----------



## anomie (Nov 19, 2008)

I've used pkg-orphan (which you mentioned) for this purpose. Did you use it with the -r option?


----------



## DutchDaemon (Nov 19, 2008)

Isn't that something `portmaster -s` should be able to do? Never tested it myself.


```
-s  clean out stale ports that used to be depended on
```


----------



## mousaka (Nov 19, 2008)

I use pkg_cutleaves.

mousaka


----------



## SeanC (Nov 19, 2008)

I second pkg_cutleaves, but proceed with caution. Portsclean (with -C -DD and -L options) is also handy to clean out distfiles.


----------

