On Tue, 29 Aug 2017 11:14:47 +0200 Christian Schrötter wrote:
> > I think update-command-not-found should make it clearer that you need to
> > update the apt-cache prior to running it.
>
> Indeed, that would be great.
I was running into this problem just now, and after remembering how to
write Python 2 code, here is a small patch that should do the job :-)
Cheers,
- Roland
--- /usr/sbin/update-command-not-found 2016-11-15 20:39:52.000000000 +0100
+++ debian/update-command-not-found 2018-03-11 21:01:32.084066383 +0100
@@ -69,7 +69,13 @@
def write_db_apt_file():
import glob
- for fname in glob.glob('/var/lib/apt/lists/*Contents*.*'):
+ content_files = glob.glob('/var/lib/apt/lists/*Contents*.*')
+ if len(content_files) == 0:
+ print 'No files /var/lib/apt/lists/*Contents*.* found.'
+ print 'Please run "apt update" before using this command.'
+ sys.exit()
+
+ for fname in content_files:
if "Contents-source" in fname:
continue
if fname.endswith(".diff_Index"):