Command to only clear caches from yay (leave pacman parts untouched)
Is your feature request related to a problem? Please describe.
I'm always frustrated when I enter yay -Sc --noconfirm to clean up substantial amounts of space (primarily build artifacts and packages in .cache/yay), but yay also removes older versions of installed packages from my pacman cache.
I understand that pacmans behaviour is the same when using -Sc, but that's why I use paccache. Having older versions of packages has quite literally saved my day multiple times.
Describe the solution you'd like
yay -Sc --aur (or similar) doing only the last two steps of cleaning (remove all other AUR packages from cache / remove ALL untracked AUR files). Sadly yay -Yc is already taken
Ideally also a corresponding option, to be remembered in config.json.
Describe alternatives you've considered
Running echo -ne n\ny\ny\ny | yay -Sc
Although it is doable, it makes the clean command a lot less ergonomic (which it clearly is meant to be, since it tries to one-command clean all relevant parts of both package managers). Also, losing a lot of old package versions by accident is no joke IMHO.
Additionally, I personally find the info "Packages to keep: All locally installed packages" misleading, because to me that's to close to "delete only versions of not installed packages", while it actually (apparently) means "delete every version of a package thats not the installed one). So maybe additionally add CAVEATs to manpage and command output?
Additional context
#354 is not about the same problem but mentions the behaviour
This is the output I get when running yay -Sc --aur or yay -Sca. Is this the behavior you are expecting? If so, this feature is already implemented.
$ yay -Sc --aur
Build directory: /home/user/.cache/yay
:: Do you want to remove all other AUR packages from cache? [Y/n]
removing AUR packages from cache...
:: Do you want to remove ALL untracked AUR files? [Y/n]
removing untracked AUR files from cache...
Is there available config option to do so automatically after build and install package? I'm keeping my cache directory in the /tmp/ directory and don't wan't to keep anything there except some rare cases.
Is there available config option to do so automatically after build and install package?
I use a Pacman hook to do this automatically for me. This is what mine looks like.
[Trigger]
Type = Package
Operation = Upgrade
Operation = Remove
Target = *
[Action]
Description = Cleaning Yay cache...
When = PostTransaction
Exec = /usr/bin/sudo -u <username> -- /usr/bin/yay --sync --clean --aur --noconfirm
@jdholtz, thanks, interest idea. I've used yaourt and am trying to switch to yay since yaourt is deprecated. I'm trying to determine if it's possible to have the same behavior for the build directory. If I enable the mentioned pacman hook, it could potentially remove all my parallel work if I'm building two packages at the same time or if one package was built and I forgot about it while starting to build and install another package.
So, I'm looking for functionality in yay that allows cleanup of the exact directory that was built.
So, I'm looking for functionality in yay that allows cleanup of the exact directory that was built.
I don't know of any functionality in Yay specifically for that. However, makepkg may have flags that do what you are looking for.
There is a potential "hack" you can do by setting Yay's --builddir before cleaning the cache. Any directory in that builddir will be cleaned (if it has a .git folder). You may be able to use this to get your desired functionality.
Hey @t-nil you might have some success with --cleanafter. It's not a complete clean but it's close
--cleanafter
Remove untracked files after installation.
Untracked files are removed with the exception
of directories. This allows VCS packages to
easily pull an update instead of having to
reclone the entire repo.