You are not logged in.

#1 2024-05-29 10:16:27

zse
Member
Registered: 2024-05-28
Posts: 21

Simply clearing package cache after successful update?

I have used Arch for years and, as far as I know, never actively used the package cache for anything. I never needed to downgrade a package and I don't remember ever reinstalling an uninstalled package.

So I am thinking about adding "pacman -Scc" (or "paccache -rk0") after a successful "pacman -Syu" to my system update routine.

Is there anything I am missing of why that might not be a good idea? Is the cache used for anything else that I'm not considering?

Offline

#2 2024-05-29 11:43:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Simply clearing package cache after successful update?

I have lived in my home for many years and never needed my fire extinguisher - but that doesn't mean I'm going to get rid of it.

The package cache is not used for any other purposes - so strictly speaking you can clear it all away on a regular basis, but I'd strongly advise against it.  Proper use of paccache cleaning can keep the space used by the cache pretty trivial while still providing a good safety net in case anything does go wrong.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2024-05-29 12:22:55

zse
Member
Registered: 2024-05-28
Posts: 21

Re: Simply clearing package cache after successful update?

I am having a hard time imagining what problems that cache is a "good safety net" for. Wouldn't the system need to be so broken that it couldn't access the net anymore for it being really useful? That seems extremely specific to me.

Anyway, thanks for confirming. For me it is not even that big of a deal should the system get completely borked, I always can reinstall the whole system in like 45minutes, so the worst case scenario this cache could help with doesn't scare me all that much.

Offline

#4 2024-05-29 12:26:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Simply clearing package cache after successful update?

I've used the cache to recover from problems at least a dozen times.  But if you keep a installation flash drive around and are okay spending 45 minutes starting from scratch, go for it.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2024-05-29 12:59:20

c00ter
Member
From: Alaskan in Washington State
Registered: 2014-08-28
Posts: 421

Re: Simply clearing package cache after successful update?

Go ahead, make Murphy's day.


UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. -- Doug Gwyn

Offline

#6 2024-05-29 13:40:51

Fuxino
Member
From: Slovakia
Registered: 2014-09-26
Posts: 198

Re: Simply clearing package cache after successful update?

I use this: https://aur.archlinux.org/packages/paccache-hook

You can configure how many old versions to keep in the cache (both for currently installed and not installed packages). So you can keep some packages in the cache, just in case, and automatically clean older versions, so the cache doesn't grow too much.


Arch + XMonad

Dotfiles: https://github.com/Fuxino/dotfiles

Offline

#7 2024-05-29 14:07:43

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,487
Website

Re: Simply clearing package cache after successful update?

Why use -Scc in that case....  Just set CacheDir=/tmp in your pacman.conf.

Offline

#8 2024-05-29 14:24:49

zse
Member
Registered: 2024-05-28
Posts: 21

Re: Simply clearing package cache after successful update?

CacheDir=/tmp doesn't seem like a great idea. It means the downloaded (potentially gigabytes of) packages stay uselessly in RAM until you restart or clean the cache, right? And it might be nice to have the cache temporarily, should an update fail and need a system reboot.

I'm still kind of curious what actual problems that cache helps. Downgrading packages is generally not recommended (as that may result in dependency problems) and preventing re-downloading previously uninstalled packages again seems hardly a problem unless you for some weird reason do that frequently...

Last edited by zse (2024-05-29 14:34:47)

Offline

#9 2024-05-29 15:05:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Simply clearing package cache after successful update?

My fire extinguisher comparison was chosen for a reason.  Fire extinguishers seem pretty silly by the same logic, right?  You should have no need for them unless you do something stupid.  Don't leave unattended open flames, keep the stove clean, etc.  If you manage your home right, you really shouldn't have fires.  But the extinguisher isn't there for expected outcomes, it's there for the unexpected ones when things go wrong.

Again, feel free to empty your cache if you'd like, but asking when it would be used is kinda' missing the point.  It really shouldn't be needed in any routine or predictable way.  But when shit hits the fan in some unexpected way, it can save a whole lot of trouble (and perhaps data compared to a reinstall).

The last time that I recall needing my cache was when I was removing packages I didn't think I needed.  There was a new dependency added for wpa_supplicant that was never needed before.  I hoped to purge my system of that dependency that provided a feature I had absolutely no use for.  But I failed to realize that the wpa_supplicant in our repos was built in such a way that the wpa_supplicant binary itself now linked to a shared library of this completely-useless-to-me optional tool.  So the next time I rebooted, wpa_supplicant itself failed to even run at all.  I had no available ethernet, so I would have been pretty screwed if I couldn't `pacman -U /var/cache/useless-package.pkg.tar.xz` and reboot.  I now build my own wpa_supplicant variant with the relevant compile flags to exclude that useless-to-me bloat and it runs fine without that other package.  But as I explored that issue, the cache saved my ass.

The time before that I don't recall exactly what I had modified, but I changed some config file in some experimentation.  Somehow my configuration edits resulted in a critically disabled system.  I couldn't get internet access to look up what the default config was to reset things.  But I was able to extract the default config from the cached package file and fixed my error in no time.

Now those stories probably don't mean anything to you - nor should they.  The odds of you needing to use a cached package for a similar reason I did is virtually zero.  But that doesn't mean there couldn't be other screw ups in which it could save you.  The cache isn't there to save you from foreseeable problems - it's there to save you from unforeseen problems.  So saying you can't foresee what such problems would be really is beside the point.

Are you running that low on space?  Otherwise what cost is there to keeping recent packages in the cache?

But again, it's your system.  If you don't want to learn from the experience of others, you'll be sure to learn from your own experience.

Last edited by Trilby (2024-05-29 15:07:36)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#10 2024-05-29 15:54:21

seth
Member
Registered: 2012-09-03
Posts: 60,378

Re: Simply clearing package cache after successful update?

Fire extinguishers are useless for nerds

Bottom line is if you've the means and are ok to fix the system offline w/ internet access (ie. from the install iso) and are willing to bet on the ALA not being down right when you need it and are ok in taking the slight downtime that's gonna be required for that, there's no point in having a local cache.

If you're running out of space, see Allan's comment - you can just point the cache to another partition.

I'll point out that

So I am thinking about adding "pacman -Scc" (or "paccache -rk0") after a successful "pacman -Syu" to my system update routine.

this is bad logics - just because "pacman -Syu" was "successful" does not at all mean that the update didn't maneuver you into a position where you're gonna need the cache.
The measure of success here is "it's the next day, I rebooted and my important stuff all still works".

Offline

#11 2024-05-29 15:54:34

zse
Member
Registered: 2024-05-28
Posts: 21

Re: Simply clearing package cache after successful update?

Hehe, I see. Thx for that anecdote.

I'm not really running low on disk space, though I never cleared it and recently noticed the cache taking more than everything else combined on my system root partition. And since I do have plenty of other options to get to a working system (should this one not boot correctly), I don't think I need that particular safety net. As I already am using my own little script to run system updates, just amending that to clear the cache after a successful update seems like the easiest solution to never have to think about this again. I just like to keep things as simple as possible.

Offline

#12 2024-05-29 15:56:11

seth
Member
Registered: 2012-09-03
Posts: 60,378

Re: Simply clearing package cache after successful update?

I never cleared it and recently noticed the cache taking more than everything else combined

So use only one "c"?

Offline

#13 2024-05-29 16:03:14

zse
Member
Registered: 2024-05-28
Posts: 21

Re: Simply clearing package cache after successful update?

seth wrote:

The measure of success here is "it's the next day, I rebooted and my important stuff all still works".

Right, I know. For the purpose of my script a successful update is a close enough approximation of that though. Should it still break after a reboot as I said I have other options.

Offline

Board footer

Powered by FluxBB