Bug 252055

Summary: pkg-clean is emptying cache directory
Product: Ports & Packages Reporter: Usama Khan <usama.cit>
Component: Individual Port(s)Assignee: freebsd-pkg (Nobody) <pkg>
Status: Closed FIXED    
Severity: Affects Many People CC: Trond.Endrestol, colin, dpetrov67, franco, garethwynroberts1, pkg, whukriede
Priority: --- Flags: linimon: maintainer-feedback? (pkg)
Version: Latest   
Hardware: Any   
OS: Any   
Description Flags
Fix to restore documented behaviour for pkg_clean version 16 none

Description Usama Khan 2020-12-22 19:51:42 UTC
"pkg clean" is removing everything from the cache directory.

"pkg clean" (without any option/argument) removes packages that have been superseded by newer versions, and any packages that are no longer provided. Moreover, in order to remove all the packages from the cache, "pkg clean -a" is used. However, it is observed that even without giving an "-a" option, "pkg clean" is deleting all cached packages including those, which have not been superseded by newer versions yet and are still in use.
Comment 1 Wolfgang Hukriede 2021-04-17 19:34:38 UTC
Yes, I can confirm this. "pkg clean -n" also shows the full set.
Comment 2 Trond.Endrestol 2021-07-13 08:25:13 UTC
I created https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249917 some time ago. It's a good thing more people are experiencing this odd behaviour, and hopefully it will be fixed.
Comment 3 garethwynroberts1 2021-08-11 21:40:31 UTC
Created attachment 227121 [details]
Fix to restore documented behaviour for pkg_clean version 16
Comment 4 garethwynroberts1 2021-08-11 21:43:50 UTC
This bug is fixed in pkg version 1.17.0 and 1.17.1

If you are stuck on previous versions, e.g. pkg-1.16.3, this simple one-character patch will fix the problem.