Dnf system-upgrade ignores system_state_dir config option

In Fedora 41 dnf system-upgrade was changed to download files to /usr rather than /var as before (see Dnf system-upgrade, package location ).

According to the dnf documentation it should be possible to control this by setting the system_state_dir option in the [main] section of /etc/dnf/dnf5.conf (or /etc/dnf/dnf.conf, depending on where in the documentation one reads). I tried putting the following in both /etc/dnf/dnf5.conf and /etc/dnf/dnf.conf:

[main]
system_state_dir=/var/lib/sysimage/libdnf5

But after setting system_state_dir, dnf system-upgrade still downloads to /usr rather than /var. Any idea why this configuration option isn’t having the intended effect?

My guess is that was a dnf4 option.
Did you check in the dnf5 docs if this is still supported in this way?

You may need to report this as a bug How to file a bug :: Fedora Docs

The docs say that system_state_dir is still used in dnf5.

However, according to the docs, the directory specified as the system_state_dir is used to:

  1. Store the reasons why each installed package was added to the system. The reasons can be “user” for packages that the user explicitly asked DNF5 to install, “dependency” and “weak dependency” for packages pulled in as dependencies of another package, “group” for packages installed by a group, or “external” for packages installed by another tool (e.g. rpm).
  2. Track installed groups and packages installed by these groups.
  3. Track installed environmental groups.

It doesn’t sound like it’s the directory that packages are actually downloaded into.

By default, the packages are downloaded to /usr/lib/sysimage/libdnf5/offline, but I would think it would make more sense to download the packages to a cache directory

Discusses this.

2 Likes

Following the trail from that, it looks like this change will download packages into persistdir (which by default is /var/lib/dnf) instead of somewhere under /usr.

It was merged into dnf5 version 5.3.0.0 which at the time of writing is in Rawhide, but not yet any released Fedora version.

The change in offline: Store downloaded packages in /var/lib/dnf (#2442) does address my problem, but I’m trying to upgrade from F41 so the change in Rawhide doesn’t help me (yet).

I’m confused by the discussion in dnf system-upgrade downloads several gigabytes to /usr/lib (#2398). The phrase “hard coded” is used at least twice, but in one of those places it says the path is “currently hard-coded to the system state dir.” This would seem to contradict the documentation saying system_state_dir can be overridden with a config file might be incorrect. Can anyone confirm whether system_state_dir can in fact be overridden?

You can save time and simply create a symlink:

sudo mv -f -t /var/lib/dnf /usr/lib/sysimage/libdnf5/offline
sudo ln -f -s -T /var/lib/dnf/offline /usr/lib/sysimage/libdnf5/offline

Thanks, I did just that and it worked. Had previously hesitated to do that based on the discussion in Dnf system-upgrade, package location in which it was suggested that the symlink approach might require some “bravery” but I encountered no problems.

1 Like