apt_check.py crashes with exception "AttributeError"

Bug #1943638 reported by No Spam
38
This bug affects 7 people
Affects Status Importance Assigned to Milestone
update-notifier (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

On my Ubuntu server, I received the message for quite some time (> 1 year):
"The list of available updates is more than a week old"

I regularly run "apt update", so the message simply isn't true.
After some research, I manage to identify the script "/usr/lib/update-notifier/apt-check" as the root cause.
When executed with parameter "--human-readable", the following exception is thrown.
Without "--human-readable", no exception is thrown.

Traceback (most recent call last):
  File "/usr/lib/python3.8/pdb.py", line 1705, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python3.8/pdb.py", line 1573, in _runscript
    self.run(statement)
  File "/usr/lib/python3.8/bdb.py", line 580, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/usr/lib/update-notifier/apt_check.py", line 6, in <module>
    import apt
  File "/usr/lib/update-notifier/apt_check.py", line 477, in run
    write_human_readable_summary(sys.stdout, upgrades, security_updates,
  File "/usr/lib/update-notifier/apt_check.py", line 249, in write_human_readable_summary
    esm_distro = is_esm_distro()
  File "/usr/lib/update-notifier/apt_check.py", line 150, in is_esm_distro
    DISTRO in ubuntu_distro.supported_esm()
AttributeError: 'UbuntuDistroInfo' object has no attribute 'supported_esm'
Uncaught exception. Entering post mortem debugging

Ubuntu version:

# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Revision history for this message
No Spam (spam-receiver) wrote :

As a simple solution, I added a "try ... except" block around line 150. This solved the issue.

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

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

Changed in update-notifier (Ubuntu):
status: New → Confirmed
Revision history for this message
Brian Murray (brian-murray) wrote :

What version of distro-info do you have installed? Do you happen to have a pip version of distro-info installed? There was an out of date version of distro-info in pypi that didn't have all the features of the one from the Ubuntu archive.

Changed in update-notifier (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Brian Murray (brian-murray) wrote :

For the record this works fine for me.

bdmurray@clean-focal-amd64:~$ /usr/lib/update-notifier/apt-check --human-readable
34 updates can be applied immediately.
13 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
bdmurray@clean-focal-amd64:~$ apt-cache policy distro-info
distro-info:
  Installed: 0.23ubuntu1
  Candidate: 0.23ubuntu1
  Version table:
 *** 0.23ubuntu1 500
        500 http://192.168.10.7/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status

Revision history for this message
No Spam (spam-receiver) wrote :

In reply to #3:

# apt list | grep distro-info

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

distro-info-data/focal-updates,focal-security,now 0.43ubuntu1.9 all [Installiert,automatisch]
distro-info/focal,now 0.23ubuntu1 amd64 [Installiert,automatisch]
libdistro-info-perl/focal 0.23ubuntu1 all
python3-distro-info/focal,now 0.23ubuntu1 all [Installiert,automatisch]

Revision history for this message
Brian Murray (brian-murray) wrote :

Could you answer the second part of the question "Do you happen to have a pip version of distro-info installed? There was an out of date version of distro-info in pypi that didn't have all the features of the one from the Ubuntu archive."

Revision history for this message
No Spam (spam-receiver) wrote :

How do I find out?

Revision history for this message
Brian Murray (brian-murray) wrote : Re: [Bug 1943638] Re: apt_check.py crashes with exception "AttributeError"

On Mon, Jan 10, 2022 at 05:12:48PM -0000, No Spam wrote:
> How do I find out?

pip list should do the trick.

--
Brian Murray

Revision history for this message
No Spam (spam-receiver) wrote :

$ pip list | grep distro-info
distro-info 1.0

Revision history for this message
No Spam (spam-receiver) wrote :

$ sudo pip list | grep distro-info
distro-info 0.0.0

Revision history for this message
Brian Murray (brian-murray) wrote :

If you remove or update the pip install of distro-info for the root user this issue should be resolved.

Revision history for this message
No Spam (spam-receiver) wrote :

Thanks!

$ sudo pip uninstall distro-info
Found existing installation: distro-info 0.0.0
Uninstalling distro-info-0.0.0:
  Would remove:
    /usr/local/lib/python3.8/dist-packages/distro_info-0.0.0.dist-info/*
    /usr/local/lib/python3.8/dist-packages/distro_info.py
    /usr/local/lib/python3.8/dist-packages/distro_info_test/*
Proceed (Y/n)?
  Successfully uninstalled distro-info-0.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

$ sudo pip list | grep distro-info
distro-info 0.23ubuntu1

Revision history for this message
No Spam (spam-receiver) wrote :

Same for my user:

$ pip uninstall distro-info
Found existing installation: distro-info 1.0
Uninstalling distro-info-1.0:
  Would remove:
    /mnt/data/home/thomas/.local/lib/python3.8/site-packages/distro_info-1.0.dist-info/*
    /mnt/data/home/thomas/.local/lib/python3.8/site-packages/distro_info.py
Proceed (Y/n)?
  Successfully uninstalled distro-info-1.0

$ pip list | grep distro-info
distro-info 0.23ubuntu1

Revision history for this message
Brian Murray (brian-murray) wrote :

So did removing the pip version of distro-info resolve the issue for you?

Revision history for this message
No Spam (spam-receiver) wrote :

Yes, it seems to be solved after I reverted the changes I made to apt-check.py

Changed in update-notifier (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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