DNF Modularity: Transitioning software streams in AlmaLinux 9
0 reputation · 28 Aug 2020, 11:43 UTC
0 reputation · 28 Aug 2020, 11:43 UTC
AlmaLinux 9 uses the DNF package manager with the AppStream model, allowing multiple versions of a software stream (e.g., Node.js, Python) to coexist.
When a system has a module stream already enabled, switching to another stream often triggers dependency conflicts because the previous stream’s packages remain installed.
Current documentation states that a dnf module reset is usually required before activating a new stream, but it is unclear whether this command fully cleans all related dependencies or if manual intervention is necessary.
dnf module reset remove all packages that belong to the previous stream, or are some retained?To switch software streams in AlmaLinux 9 without leaving orphaned packages, you must combine a module reset with a package synchronization command. The precise sequence is:
sudo dnf module reset <module_name>sudo dnf module enable <module_name>:<stream_version>sudo dnf distro-syncIf you are installing the software for the first time in the new stream, replace distro-sync with sudo dnf module install <module_name>.
It is a common misconception that dnf module reset removes installed software. It does not.
The reset command only modifies the DNF metadata state. It clears the "enabled" flag and the specific stream selection for that module in the local database. It does not trigger the removal of any RPM packages currently residing on the disk. Consequently, if you enable a new stream and attempt to install it without a synchronization step, DNF may encounter dependency conflicts because the packages from the previous stream are still present and active.
Because reset only affects metadata, manual or synchronized intervention is required to clean the system:
sudo dnf remove <package_name>) before performing the reset and enable sequence.To verify the transition was successful and no legacy versions remain, use the following commands:
# Check which stream is currently active
dnf module list --enabled
# Verify the actual installed version of the software
<software_command> --version
Diagnostic Detail Needed: Are you switching between streams of the same major version (e.g., Node.js 16 to 18) or moving from a modular stream to a standard non-modular package? The latter may require a full dnf remove of the module before the standard package can be installed.
Use comments to ask for clarification. Post a solution as an answer.
32,775 reputation · 28 Aug 2020, 17:56 UTC
The dnf module switch-to : command combines a reset, enable, and install step in a single transaction. It will automatically remove packages that belong to the current stream and install those from the target stream, resolving dependencies as part of the operation.
However, switch-to only touches packages that are part of the module’s metadata. Packages that were installed as dependencies of the previous stream but are not tied to any module (e.g., libraries or utilities pulled in by the stream’s packages) are not removed automatically. After using switch-to, you may still need to run:
sudo dnf distro-sync to bring the system to the exact set of packages offered by the newly enabled stream, orsudo dnf autoremove to clean up orphaned dependencies that are no longer required.This ensures a clean transition without leaving orphaned or conflicting packages.