Bug 2395810

Summary: legacy /var/cache/dnf still exists, contains files
Product: [Fedora] Fedora Reporter: Chris Murphy <bugzilla>
Component: dnfAssignee: rpm-software-management
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 43CC: daniel.mach, jmracek, jonathan, jrohel, mblaha, packaging-team-maint, pkratoch, ppisar, rpm-software-management
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-09-16 14:53:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Chris Murphy 2025-09-16 14:33:47 UTC
I notice with upgraded systems that /var/cache/dnf still exists, and it contains old crusty bits. dnf5 uses /var/cache/libdnf5, so /var/cache/dnf is just going stale, taking up space, could (speculatively) cause issues for PackageKit (see bug https://bugzilla.redhat.com/show_bug.cgi?id=2372978#c9)

I think the dnf5 RPM should probably clean this up on behalf of the old version?


Reproducible: Always

Steps to Reproduce:
I've noticed this on systems (major version) upgraded using dnf, and gnome-software

Actual Results:
/var/cache/dnf still exists and contains significant amount of files

Expected Results:
/var/cache/dnf should not exist or be empty

Comment 1 Petr Pisar 2025-09-16 14:44:30 UTC
/var/cache/dnf is used by DNF4 (python3-dnf package).

Regarding removing its content, it could be done when uninstalling python3-dnf with a postun scriptlet. But there is a problem that DNF4 has no idea which files there were created by DNF4 which files were saved there by someone else. In RPM world, the "best" practice is not to touch files the RPM package does not own. I.e. keep the cruft there for system administrator's discretion.

AFAIK in the past there was (unrelated to DNF) cron job which scanned /tmp and removed long time unused files. That cron job would the best solution for these cache files. But I worry it does not exist anymore.

Comment 2 Petr Pisar 2025-09-16 14:53:57 UTC

*** This bug has been marked as a duplicate of bug 2221663 ***