Bug 1733274 - Uninstalling a package previously installed with PackageKit using dnf does not uninstall any unused dependencies
Summary: Uninstalling a package previously installed with PackageKit using dnf does no...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: libdnf
Version: 39
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: AcceptedFreezeException
Depends On: 1650310
Blocks: F39FinalFreezeException
TreeView+ depends on / blocked
 
Reported: 2019-07-25 14:58 UTC by Daniel Rusek
Modified: 2023-10-22 08:24 UTC (History)
26 users (show)

Fixed In Version: libdnf-0.72.0-1.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-10-22 08:24:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github PackageKit PackageKit issues 201 0 None closed Should remove unused dependencies (DNF backend) 2022-01-01 14:19:36 UTC
Github PackageKit PackageKit pull 526 0 None Merged dnf: Add support for autoremove flag when removing packages 2022-01-01 14:19:36 UTC

Description Daniel Rusek 2019-07-25 14:58:04 UTC
Description of problem:
When uninstalling a package previously installed with PackageKit (GNOME Software or pkcon) on latest Fedora Rawhide using dnf remove, dnf does not find any unused dependencies and uninstalls only the base package. No dependencies are also found when running dnf autoremove afterwards. This seems to be a dnf regression, see the link from Additional info.

Version-Release number of selected component (if applicable):
dnf-4.2.7-2.fc31.noarch
PackageKit-1.1.12-10.fc31.x86_64

How reproducible:
Every time.

Steps to Reproduce:
1. Install some package that has additional dependencies with pkcon.
2. After the installation, try uninstalling the package using "dnf remove".

Actual results:
Only the base package is uninstalled.

Expected results:
Both the base package and the previously installed dependencies are uninstalled.

Additional info:
https://github.com/hughsie/PackageKit/issues/201#issuecomment-515067267

Comment 1 Jaroslav Mracek 2019-07-25 17:57:27 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.

Comment 2 Daniel Rusek 2019-07-28 20:02:46 UTC
Let's hope that GNOME Software will soon switch to libdnf instead of using PackageKit. :-)

Comment 3 Daniel Rusek 2019-08-04 12:42:22 UTC
I have tested this with various Fedora versions and it seems that the issue happens since Fedora 29. It worked fine in Fedora 28.

Comment 4 Ben Cotton 2019-08-13 17:02:09 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.

Comment 5 Ben Cotton 2019-08-13 18:34:42 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to 31.

Comment 6 Daniel Rusek 2019-08-26 18:30:27 UTC
So what is the status here? Any chance this will be fixed (in dnf or PackageKit)?

Comment 7 Ben Cotton 2020-02-11 15:48:06 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 32 development cycle.
Changing version to 32.

Comment 8 Daniel Rusek 2020-10-06 12:26:48 UTC
Still the same issue on Fedora 33.

Comment 9 Ben Cotton 2021-02-09 15:11:06 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 10 Daniel Rusek 2021-05-14 13:38:03 UTC
Still a problem.

Comment 11 Richard Hughes 2021-05-14 15:00:23 UTC
> 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.

Comment 12 Ben Cotton 2021-08-10 12:46:01 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 35 development cycle.
Changing version to 35.

Comment 13 "FeRD" (Frank Dana) 2022-01-01 14:19:37 UTC
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.)

Comment 14 Daniel Rusek 2022-01-01 20:18:39 UTC
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.

Comment 15 Milan Crha 2022-01-03 11:10:34 UTC
> 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.

Comment 16 Daniel Rusek 2022-02-24 14:28:08 UTC
Still the same issue on latest Rawhide, however since PackageKit 1.2.5, a "pkcon remove <package> --autoremove" command can be used instead.

Comment 17 Ben Cotton 2022-11-29 16:46:30 UTC
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.

Comment 19 Jonathan Wakely 2022-11-30 11:14:23 UTC
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.

Comment 20 Jonathan Wakely 2022-11-30 11:17:22 UTC
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.

Comment 21 Milan Crha 2022-11-30 16:04:25 UTC
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.

Comment 22 Jonathan Wakely 2022-11-30 16:17:49 UTC
Yes, I can do that. You mean PK upstream, not DNF upstream, right?

Comment 23 Milan Crha 2022-11-30 16:24:46 UTC
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.

Comment 24 Ben Cotton 2023-02-07 14:51:16 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 25 Fedora Release Engineering 2023-08-16 07:04:23 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.

Comment 26 Alessandro Astone 2023-10-02 14:17:52 UTC
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.

Comment 27 "FeRD" (Frank Dana) 2023-10-04 18:03:03 UTC
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?

Comment 28 Alessandro Astone 2023-10-04 18:08:26 UTC
They will keep their userinstalled status

Comment 29 Fedora Update System 2023-10-18 15:10:34 UTC
FEDORA-2023-a066057708 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-a066057708

Comment 30 Fedora Update System 2023-10-19 02:17:03 UTC
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.

Comment 31 Fedora Blocker Bugs Application 2023-10-19 10:10:45 UTC
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.

Comment 32 Adam Williamson 2023-10-19 20:49:25 UTC
+4 in https://pagure.io/fedora-qa/blocker-review/issue/1416 , marking accepted FE.

Comment 33 Fedora Update System 2023-10-20 02:12:21 UTC
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.

Comment 34 Fedora Update System 2023-10-22 08:24:43 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.