Debian – How to get `command-not-found` working on Debian Stretch

command-not-founddebian

I have set up two Debian Stretch systems, one new installation by 'netinst' CD, one upgraded from Jessie.

After that, I have installed the command-not-found package.

apt install command-not-found

The installation ran smoothly, with neither errors nor warnings. As suggested in the installation process output, I ran update-command-not-found subsequently. This command does not give any output at all and returns with exit code 0 – no errors.

However, when I type some non-existing command, I get an error nevertheless:

Could not find the database of available applications, run update-command-not-found as root to fix this
foobarbaz: command not found

This happens on both systems. I have no clue how to fix this issue. What have I missed?


UPDATE:
For some reason update-command-not-found worked on my local system just now. It shows some download URLs fetching data from. Now, the console works as expected. I did nothing since this morning, the system had gone in sleep mode while I was absent.

On the remote system the issue is remaining.

Best Answer

The solution:

There were wrong entries in the /etc/apt/sources.list file. The package needs to be updated via the update repository. There has been a wrong entry derived from the provider's local Jessie mirror repository. I have changed the URLs to the original Stretch reporitory but missed to replace a slash by a dash (stretch/updates => stretch-updates).

Add to file /etc/apt/sources.list:

# stretch-updates, previously known as 'volatile'
deb http://ftp.de.debian.org/debian/ stretch-updates main contrib non-free
deb-src http://ftp.de.debian.org/debian/ stretch-updates main contrib non-free

Run:

apt update
update-command-not-found
Related Question