Removing orphaned packages

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?
 
Isn't that something portmaster -s should be able to do? Never tested it myself.

Code:
     -s  clean out stale ports that used to be depended on
 
Last edited:
I second pkg_cutleaves, but proceed with caution. Portsclean (with -C -DD and -L options) is also handy to clean out distfiles.
 
Last edited by a moderator:
This thread is 18(!) years old. It was about the old pkg_tools, not pkg(8). That didn't even exist back then.
 
This thread is 18(!) years old.
I agree not to resurrect zombie threads just for fun, but this was the one that come up at top on my search for removing orphaned packages (after an other thread helpfully listed the pkg version -vRL= command to list them). I like to leave a trail for future searchers with similar problems.
 
This thread was about the old package tools though. PKGNG was developed 4 years after this thread ended.
 
Back
Top