Bug 1733274
| Summary: | Uninstalling a package previously installed with PackageKit using dnf does not uninstall any unused dependencies | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Daniel Rusek <drusek> | 
| Component: | libdnf | Assignee: | rpm-software-management | 
| Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | 
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 39 | CC: | ales.astone, awilliam, daniel.mach, dmach, ferdnyc, hujq, jmracek, jonathan, jrohel, jwakely, klember, krinkodot22, mail, mblaha, mcrha, mhatina, n.fabritius, packaging-team-maint, pkratoch, rdieter, rhughes, roshan.shariff, rpm-software-management, smparrish, vmukhame, vtq-gnome | 
| Target Milestone: | --- | Keywords: | Triaged | 
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | AcceptedFreezeException | ||
| Fixed In Version: | libdnf-0.72.0-1.fc39 | Doc Type: | If docs needed, set a value | 
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2023-10-22 08:24:43 UTC | Type: | Bug | 
| Regression: | --- | Mount Type: | --- | 
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | 1650310 | ||
| Bug Blocks: | 2143447 | ||
| 
        
          Description
        
        
          Daniel Rusek
        
        
        
        
        
          2019-07-25 14:58:04 UTC
        
       I beliew that the problem is what is stored in transaction database (swdb) after PackageKit transaction. I would like to ask PackageKit maintainers to take a look (I know that the code is probably in libdnf, but originate a lot from libhif). If you don't want to fix it please close it as a won't fix as a sign that PackageKit is unmaintained. Let's hope that GNOME Software will soon switch to libdnf instead of using PackageKit. :-) I have tested this with various Fedora versions and it seems that the issue happens since Fedora 29. It worked fine in Fedora 28. This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle. Changing version to '31'. This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle. Changing version to 31. So what is the status here? Any chance this will be fixed (in dnf or PackageKit)? This bug appears to have been reported against 'rawhide' during the Fedora 32 development cycle. Changing version to 32. Still the same issue on Fedora 33. This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle. Changing version to 34. Still a problem. > Let's hope that GNOME Software will soon switch to libdnf instead of using PackageKit
We can do that when dnfdaemon exists. Until then we need PK to act as the privileged helper.
This bug appears to have been reported against 'rawhide' during the Fedora 35 development cycle. Changing version to 35. https://github.com/PackageKit/PackageKit/pull/526 This should be fixed in PackageKit upstream as of three days ago, when Neal Gompa merged the above PR (closing a 3.5-year-old Issue in the process). The PR added support for properly setting (or NOT setting) 'userinstalled' flags on dependencies installed by PackageKit. (Which means packages it installs only as *dependencies* of packages requested by the user will properly show up as `dnf autoremove` candidates, and will be included in uninstall transactions if the packages that pulled them in are being removed.) Nice, great work! It will also be needed to enabled the "packagekit_autoremove" build option in GNOME Software Fedora spec file to have this also working in GUI on Fedora Workstation. Adding Milan Crha to CC. > It will also be needed to enabled the "packagekit_autoremove" build option in GNOME Software Fedora spec file to have this also working in GUI on Fedora Workstation.
It requires a PackageKit build with the change added, to add a dependency on it, otherwise the package removal can fail as "not supported" with older PackageKit version.
I suggest to close this bug and open a new gnome-software bug once the PackageKit with that fix reaches rawhide.
Still the same issue on latest Rawhide, however since PackageKit 1.2.5, a "pkcon remove <package> --autoremove" command can be used instead. This message is a reminder that Fedora Linux 35 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a 'version' of '35'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, change the 'version' to a later Fedora Linux version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora Linux 35 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora Linux, you are encouraged to change the 'version' to a later version prior to this bug being closed. Could this be fixed by https://src.fedoraproject.org/rpms/gnome-software/c/913366d7d63e62d9fbd302a9c820237b69ad3df2?branch=rawhide , aka bug #2056082 ? No, because the flag of whether a dependency can be autoremoved is still not set when installing via pkcon.
[root@carbon ~]# pkcon install tesseract
Resolving                     [=========================]         
Loading cache                 [=========================]         
Testing changes               [=========================]         
Finished                      [                         ] (0%)  
The following packages have to be installed:
 leptonica-1.82.0-6.fc36.x86_64 C library for efficient image processing and image analysis operations
 tesseract-5.0.1-5.fc36.x86_64  Raw OCR Engine
 tesseract-langpack-eng-4.1.0-3.fc36.noarch     English language data for tesseract-tessdata
Proceed with changes? [N/y] y
                              [=========================]         
Installing                    [=========================]         
Querying                      [=========================]         
Downloading packages          [=========================]         
Testing changes               [=========================]         
Installing packages           [=========================]         
Finished                      [=========================]         
[root@carbon ~]# dnf erase tesseract
Dependencies resolved.
============================================================================================================================================================
 Package                                        Architecture                   Version                                Repository                       Size
============================================================================================================================================================
Removing:
 tesseract                                      x86_64                         5.0.1-5.fc36                           @fedora                         3.5 M
Removing dependent packages:
 tesseract-langpack-eng                         noarch                         4.1.0-3.fc36                           @fedora                         3.9 M
Transaction Summary
============================================================================================================================================================
Remove  2 Packages
Freed space: 7.4 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                    1/1 
  Erasing          : tesseract-5.0.1-5.fc36.x86_64                                                                                                      1/2 
  Erasing          : tesseract-langpack-eng-4.1.0-3.fc36.noarch                                                                                         2/2 
  Running scriptlet: tesseract-langpack-eng-4.1.0-3.fc36.noarch                                                                                         2/2 
  Verifying        : tesseract-5.0.1-5.fc36.x86_64                                                                                                      1/2 
  Verifying        : tesseract-langpack-eng-4.1.0-3.fc36.noarch                                                                                         2/2 
Removed:
  tesseract-5.0.1-5.fc36.x86_64                                          tesseract-langpack-eng-4.1.0-3.fc36.noarch                                         
Complete!
[root@carbon ~]# rpm -q leptonica
leptonica-1.82.0-6.fc36.x86_64
Why is leptonica not autoremoved when removing tesseract?
If I install tesseract using dnf and then remove it, leptonica gets removed.
[root@carbon ~]# dnf install tesseract
Last metadata expiration check: 2:17:06 ago on Wed 30 Nov 2022 08:48:50 GMT.
Dependencies resolved.
============================================================================================================================================================
 Package                                        Architecture                   Version                                 Repository                      Size
============================================================================================================================================================
Installing:
 tesseract                                      x86_64                         5.0.1-5.fc36                            fedora                         1.3 M
Installing dependencies:
 leptonica                                      x86_64                         1.82.0-6.fc36                           fedora                         1.1 M
 tesseract-langpack-eng                         noarch                         4.1.0-3.fc36                            fedora                         1.7 M
Transaction Summary
============================================================================================================================================================
Install  3 Packages
Total download size: 4.2 M
Installed size: 10 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): leptonica-1.82.0-6.fc36.x86_64.rpm                                                                                   1.6 MB/s | 1.1 MB     00:00    
(2/3): tesseract-5.0.1-5.fc36.x86_64.rpm                                                                                    1.7 MB/s | 1.3 MB     00:00    
(3/3): tesseract-langpack-eng-4.1.0-3.fc36.noarch.rpm                                                                       1.9 MB/s | 1.7 MB     00:00    
------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                       3.1 MB/s | 4.2 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                    1/1 
  Installing       : leptonica-1.82.0-6.fc36.x86_64                                                                                                     1/3 
  Installing       : tesseract-langpack-eng-4.1.0-3.fc36.noarch                                                                                         2/3 
  Installing       : tesseract-5.0.1-5.fc36.x86_64                                                                                                      3/3 
  Running scriptlet: tesseract-5.0.1-5.fc36.x86_64                                                                                                      3/3 
  Verifying        : leptonica-1.82.0-6.fc36.x86_64                                                                                                     1/3 
  Verifying        : tesseract-5.0.1-5.fc36.x86_64                                                                                                      2/3 
  Verifying        : tesseract-langpack-eng-4.1.0-3.fc36.noarch                                                                                         3/3 
Installed:
  leptonica-1.82.0-6.fc36.x86_64                  tesseract-5.0.1-5.fc36.x86_64                  tesseract-langpack-eng-4.1.0-3.fc36.noarch                 
Complete!
[root@carbon ~]# dnf erase tesseract
Dependencies resolved.
============================================================================================================================================================
 Package                                        Architecture                   Version                                Repository                       Size
============================================================================================================================================================
Removing:
 tesseract                                      x86_64                         5.0.1-5.fc36                           @fedora                         3.5 M
Removing unused dependencies:
 leptonica                                      x86_64                         1.82.0-6.fc36                          @fedora                         2.9 M
 tesseract-langpack-eng                         noarch                         4.1.0-3.fc36                           @fedora                         3.9 M
Transaction Summary
============================================================================================================================================================
Remove  3 Packages
Freed space: 10 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                    1/1 
  Erasing          : tesseract-5.0.1-5.fc36.x86_64                                                                                                      1/3 
  Erasing          : tesseract-langpack-eng-4.1.0-3.fc36.noarch                                                                                         2/3 
  Erasing          : leptonica-1.82.0-6.fc36.x86_64                                                                                                     3/3 
  Running scriptlet: leptonica-1.82.0-6.fc36.x86_64                                                                                                     3/3 
  Verifying        : leptonica-1.82.0-6.fc36.x86_64                                                                                                     1/3 
  Verifying        : tesseract-5.0.1-5.fc36.x86_64                                                                                                      2/3 
  Verifying        : tesseract-langpack-eng-4.1.0-3.fc36.noarch                                                                                         3/3 
Removed:
  leptonica-1.82.0-6.fc36.x86_64                  tesseract-5.0.1-5.fc36.x86_64                  tesseract-langpack-eng-4.1.0-3.fc36.noarch                 
Complete!
The problem is that pkcon install marks everything as user-installed, including the dependencies. In this case, I asked to install tesseract, and tesseract-langpack-eng and leptonica were installed as dependencies. They should not be marked as user-installed, but pkcon does mark them as user-installed. That means leptonica won't be autoremoved.
This is not about gnome-software, it's about using dnf. The UX with dnf is degraded if you ever allow PackageKit (or any frontend like pkcon or Discover or gnome-software) to update and install packages, because PK does not correctly record the "user installed" flag for dependencies that were not explicitly user-installed. I see, thanks for the detailed explanation. Would it make sense to fill this upstream? The last time I asked there something, the DNF backend maintainer was quite responsive. Yes, I can do that. You mean PK upstream, not DNF upstream, right? Correct, the PackageKit upstream: https://github.com/PackageKit/PackageKit/ For what it's worth, I tried this in Fedora 37 with PackageKit-1.2.5-2.fc37.x86_64 libdnf-0.68.0-1.fc37.x86_64 and it behaves the same as you said at comment #19. This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle. Changing version to 38. This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle. Changing version to 39. This is now fixed in libdnf upstream: https://github.com/rpm-software-management/libdnf/pull/1628 Unfortunately it is not retroactive as the dependencies previously installed by packagekit are already committed as userinstalled to the database. Still, it's something! I wonder if the next system upgrade will correct that, for affected users? Or will the upgraded packages all inherit the userinstalled status? They will keep their userinstalled status FEDORA-2023-a066057708 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-a066057708 FEDORA-2023-a066057708 has been pushed to the Fedora 39 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-a066057708` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-a066057708 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. Proposed as a Freeze Exception for 39-final by Fedora user asciiwolf using the blocker tracking app because: When uninstalling a package previously installed with PackageKit using dnf, no unused dependencies are found and removed. This was fixed in the latest dnf/libdnf update, however the fix is not retroactive as the dependencies previously installed by PackageKit are already committed as userinstalled to the database. Because of this, it would be a good idea to push this fix into F39 before the Final release. +4 in https://pagure.io/fedora-qa/blocker-review/issue/1416 , marking accepted FE. FEDORA-2023-a066057708 has been pushed to the Fedora 39 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-a066057708` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-a066057708 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2023-a066057708 has been pushed to the Fedora 39 stable repository. If problem still persists, please make note of it in this bug report. |