1

to save a disk space, i've enabled Acquire::GzipIndexes "true"; in apt configuration.

now, when apt update is executed the following error occurs

raceback (most recent call last):
  File "/usr/lib/cnf-update-db", line 26, in <module>
    col.create(db)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 94, in create
    self._fill_commands(con)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 138, in _fill_commands
    self._parse_single_commands_file(con, fp)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 176, in _parse_single_commands_file
    suite=tagf.section["suite"]
KeyError: 'suite'
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code

i am using ubuntu 20.04

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

why does it happen and how can it be fixed without reverting the change? is it a bug?

Mr.
  • 415

2 Answers2

1

This seems to be bug that already has a bug report. Interestingly, it's not so much a bug in apt but rather in command-not-found. That tool is meant to react to unknown commands and suggest which packages you'd need to install to get those commands. According to the bug report

This appears to be caused by apt downloading an lz4-compressed command list for command-not-found and cnf-update-db passing the /var/lib/apt/lists/Commands-.lz4 files to db/creator.py, which does not know about the compression and attempts to parse them as plain text.

command-not-found seems to be unmaintained for at least two years. So the suggestion in the bug report is to remove it from Ubuntu's base image for future versions. If somebody wants to still use command-not-found, they can install a fixed fork (that hopefully somebody will supply) from a PPA or such.

As of now, there are two possible solutions to this problem: One is to disable Acquire::GzipIndexes in apts configuration. The other is to uninstall command-not-found, if you don't need it. Because the problem seems to appear with command-not-found specifically, I'd reckon removing this package removes the problem. But I haven't looked into any possible side effects of removing the package.

  • @karel If this answer applies to the other question as well, wouldn't it be more compliant with the ways of this site to mark the other question as a duplicate? Or am I missing something here? – Henning Kockerbeck Feb 17 '22 at 10:24
  • I want to make a canonical question that has all the possible answers to a specific error message on the same page. Otherwise if I use a non-canonical question as a duplicate target the OPs will comment that the answers on that page didn't answer their questions. – karel Feb 17 '22 at 12:48
0

I have the same issue and I managed to create a simple solution because I need both command-not-found and Acquire::GzipIndexes "true";

I've modified the file which contains the error (CommandNotFound/db/creator.py) to check if the file processed is compressed in lz4 and if it is it will be decompressed into a temporary file and use that file as normal.

To install my modified file :

sudo apt install python3-lz4; sudo wget -O /usr/lib/python3/dist-packages/CommandNotFound/db/creator.py 'https://raw.githubusercontent.com/3omar-mostafa/command-not-found-fix/main/creator.py'

You can view it on github

I hope this can help you