Aptdaemon crashes when there are any non-PEP-440 packages on the system due to setuptools 66.x.x

Bug #2008430 reported by Eugene Crosser
64
This bug affects 14 people
Affects Status Importance Assigned to Milestone
aptdaemon (Ubuntu)
Confirmed
High
Unassigned
Lunar
Confirmed
Undecided
Unassigned
setuptools (Ubuntu)
Confirmed
High
Unassigned
Lunar
Confirmed
Undecided
Unassigned
update-manager (Ubuntu)
Confirmed
High
Unassigned
Lunar
Confirmed
Undecided
Unassigned

Bug Description

"Software Updater" stopped working, it shows message "You stopped the check for updates".

update-manager.desktop[22442]: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying

Analysis shows that this is the result of aptdaemon crash when it tries to load plugins, and pkg_resources module refuses to parse non PEP-440 compliant Python package versions. There are many such python packages, one of them "devscripts", as shown in this log, but if I remove devscripts, it crashes on other packages.

org.debian.apt[22501]: File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2679, in parsed_version
org.debian.apt[22501]: self._parsed_version = parse_version(self.version)
org.debian.apt[22501]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
org.debian.apt[22501]: File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/version.py", line 266, in __init__
org.debian.apt[22501]: raise InvalidVersion(f"Invalid version: '{version}'")
org.debian.apt[22501]: pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: '2.22.2ubuntu5'
org.debian.apt[22501]: (package: devscripts)

There is an upstream ticket against setuptools: https://github.com/pypa/setuptools/issues/3772

It looks like either setuptools has to be fixed or downgraded, or aptdaemon modified to not use pkg_resources module.

There is a main ticket for fixing those non-PEP-440 packages: bug #1991606

ProblemType: Bug
DistroRelease: Ubuntu 23.04
Package: aptdaemon 1.1.1+bzr982-0ubuntu42
ProcVersionSignature: Ubuntu 5.19.0-29.30-generic 5.19.17
Uname: Linux 5.19.0-29-generic x86_64
ApportVersion: 2.24.0-0ubuntu2
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Fri Feb 24 00:16:28 2023
PackageArchitecture: all
SourcePackage: aptdaemon
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Eugene Crosser (crosser) wrote :
Revision history for this message
Amberelle Mason (amberella-777) wrote :

I opened bug #2008898 which may be a duplicate.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in aptdaemon (Ubuntu):
status: New → Confirmed
Revision history for this message
Amberelle Mason (amberella-777) wrote :

Is this still an issue? I don't see it happening anymore.

Revision history for this message
Eugene Crosser (crosser) wrote :
Download full text (5.2 KiB)

@amberella-777 that is probably because you do not have any python packages whose version pkg_resources considers "invalid". In my case, it currently stumbles on `syncthing` package (from a third party repo)

Apr 11 20:01:01 pccross org.debian.apt[6869]: 20:01:01 AptDaemon [INFO]: Initializing daemon
Apr 11 20:01:01 pccross org.debian.apt[6869]: /usr/lib/python3/dist-packages/aptdaemon/worker/pkworker.py:35: PyGIWarning: PackageKitGlib was imported without specifying a version first. Use gi.require_version('PackageKitGlib', '1.0') before import to ensure that the right version gets loaded.
Apr 11 20:01:01 pccross org.debian.apt[6869]: from gi.repository import PackageKitGlib as pk
Apr 11 20:01:01 pccross org.debian.apt[6869]: Traceback (most recent call last):
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/lib/python3/dist-packages/aptdaemon/core.py", line 1462, in __init__
Apr 11 20:01:01 pccross org.debian.apt[6869]: from .worker.pkworker import AptPackageKitWorker
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/lib/python3/dist-packages/aptdaemon/worker/pkworker.py", line 43, in <module>
Apr 11 20:01:01 pccross org.debian.apt[6869]: from ..pkutils import (bitfield_add, bitfield_remove, bitfield_summarize,
Apr 11 20:01:01 pccross org.debian.apt[6869]: ModuleNotFoundError: No module named 'aptdaemon.pkutils'
Apr 11 20:01:01 pccross org.debian.apt[6869]: During handling of the above exception, another exception occurred:
Apr 11 20:01:01 pccross org.debian.apt[6869]: Traceback (most recent call last):
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/sbin/aptd", line 39, in <module>
Apr 11 20:01:01 pccross org.debian.apt[6869]: aptdaemon.core.main()
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/lib/python3/dist-packages/aptdaemon/core.py", line 2193, in main
Apr 11 20:01:01 pccross org.debian.apt[6869]: daemon = AptDaemon(options, bus=bus)
Apr 11 20:01:01 pccross org.debian.apt[6869]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/lib/python3/dist-packages/aptdaemon/core.py", line 1466, in __init__
Apr 11 20:01:01 pccross org.debian.apt[6869]: self.worker = AptWorker(options.chroot, load_plugins)
Apr 11 20:01:01 pccross org.debian.apt[6869]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/lib/python3/dist-packages/aptdaemon/worker/aptworker.py", line 205, in __init__
Apr 11 20:01:01 pccross org.debian.apt[6869]: self._load_plugins(["modify_cache_after", "modify_cache_before",
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/lib/python3/dist-packages/aptdaemon/worker/__init__.py", line 191, in _load_plugins
Apr 11 20:01:01 pccross org.debian.apt[6869]: dists, errors = pkg_resources.working_set.find_plugins(env)
Apr 11 20:01:01 pccross org.debian.apt[6869]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 11 20:01:01 pccross org.debian.apt[6869]: File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 907, in find_plugins
Apr 11 20:01:01 pccross org.debian.apt[6869]: env = Environment(self.entries)
Apr ...

Read more...

Revision history for this message
Amberelle Mason (amberella-777) wrote :

@crosser thanks for the explanation. I'm running SyncThing in a snap.
https://gitlab.com/arubislander/syncthing-snap

Revision history for this message
Eugene Crosser (crosser) wrote :

For reference, I've submitted a pull request to syncthing-gtk to make their version PEP-440 compliant https://github.com/kozec/syncthing-gtk/pull/600.

I still think that it is wrong if any unrelated python package that is not fully standards compliant breaks the process of upgrade for the whole system.

Revision history for this message
Dan Andreșan (danyer) wrote :

In my case, rmlint-gui package was the culprit. Removed it and now I can use Software Updater (no more aptd crashes).

Changed in aptdaemon (Ubuntu):
importance: Undecided → High
tags: added: rls-nn-incoming
Changed in update-manager (Ubuntu):
importance: Undecided → High
Benjamin Drung (bdrung)
description: updated
Changed in setuptools (Ubuntu):
importance: Undecided → High
Revision history for this message
Benjamin Drung (bdrung) wrote :

There is a main ticket for fixing those non-PEP-440 packages: bug #1991606

tags: added: rls-ll-incoming
removed: rls-nn-incoming
Revision history for this message
Robie Basak (racb) wrote :

This bug was cited as justification for bug 1991606, so to help with understanding that, please could someone post steps to reproduce on a clean Ubuntu installation? Which Ubuntu releases are affected?

In particular, where did the affected /usr/lib/python3/dist-packages/pkg_resources/* come from? Is that from a package shipped by Ubuntu, and in which case, what versions are affected?

Revision history for this message
Dan Andreșan (danyer) wrote (last edit ):

Interesting thing, adding back the rmlint-gui package (which was identified like one of the culprits, see #8) and I cannot reproduce the issue. Maybe it is gone?
Later Edit: after a reboot, the problem appears once more. I will create a new comment with steps to reproduce.

Revision history for this message
Dan Andreșan (danyer) wrote (last edit ):

Steps to reproduce:

1. Install Ubuntu 23.04
2. Perform all required updates using Software Updater.
3. 'sudo apt install rmlint-gui'
4. Reboot (without reboot the bug did not reproduce)
5. Launch Software Updater
6. It will crash, see logs (08:38:56) related to apt daemon.
7. sudo apt remove rmlint-gui
8. Launch Software Updater
9. Success, see logs (08:40:20)

rmlint-gui is comming from universe repo, this is true, but the Software Updater should not crash.

Revision history for this message
Eugene Crosser (crosser) wrote :

@bdrung:

> There is a main ticket for fixing those non-PEP-440 packages: bug #1991606

this is not the point! Obviously non-PEP-440 compliant packages _in the distro_ must be fixed, independently of broken aptdaemon.

The point is that if somebody includes a third party repo, or installs a not-from-repo python package system-wide, and that package happens to be non-compliant, _it breaks distro upgrade process_. In my pretty firm opinion, it should no be this way.

I understand and agree with the wish to put more order in python packaging. Setuptools refuse to create a non-compliant package? That would be totally fair. But in this case, _uses_ who have no power to fix the problem, and may not even know what's going on, are taken hostage.

Benjamin Drung (bdrung)
tags: added: foundations-todo
removed: rls-ll-incoming
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in aptdaemon (Ubuntu Lunar):
status: New → Confirmed
Changed in setuptools (Ubuntu Lunar):
status: New → Confirmed
Changed in setuptools (Ubuntu):
status: New → Confirmed
Changed in update-manager (Ubuntu Lunar):
status: New → Confirmed
Changed in update-manager (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.