"command-not-found" doesn´t work in Debian

Hi all, :wave:

… and a Happy New Year to everybody. :heartpulse:

On my main system Lubuntu 20.04.3 LTS the “command-not-found”-package is installed by default.
So when I type e.g. kate (this text-editor is not installed) I get

kate

Command 'kate' not found, but can be installed with:

sudo snap install kate  # version 21.04.0, or
sudo apt  install kate  # version 4:19.12.3-0ubuntu1

See 'snap info kate' for additional versions.

This behaviour (which I like) seems to be triggered by the “command-not-found” package which is installed on Lubuntu:

dpkg -l | grep command-not
ii  command-not-found                             20.04.5                               all          Suggest installation of packages in interactive bash sessions
ii  python3-commandnotfound                       20.04.5                               all          Python 3 bindings for command-not-found.

So far so good. :slightly_smiling_face:

I also run Debian (Debian GNU/Linux 10 (buster)) in a VM and here the respective package is not installed. So I installed it manually.

Now that I have it available on Debian I tried it by typing kate (which isn´t installed here either) and I got the following:

kate
Could not find the database of available applications, run update-command-not-found as root to fix this
Sorry, command-not-found has crashed! Please file a bug report at:
http://www.debian.org/Bugs/Reporting
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.7.3 final 0
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster
Exception information:

local variable 'cnf' referenced before assignment
Traceback (most recent call last):
  File "/usr/share/command-not-found/CommandNotFound/util.py", line 23, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 93, in main
    if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
UnboundLocalError: local variable 'cnf' referenced before assignment

Hmm, I guess something isn´t here as it should be: :frowning_face:
The command “update-command-not-found” (run as root) had no effect either.

On Debian:

dpkg -l | grep command-not-found
ii  command-not-found                     18.04.5-1                               all          Suggest installation of packages in interactive bash sessions

In contrast to Lubuntu there´s no python3-commandnotfound installed. I´ve no idea whether that´s important (but it might be). :thinking:

Plus: there seems to be no installation candidate for that one in Debian: :exclamation:

E: Paket python3-commandnotfound kann nicht gefunden werden. # package cannot be found

Does anyone have any idea on how to get “command-not-found” running in Debian :question:

Many thanks in advance for your help.

Many greetings from Rosika. :slightly_smiling_face:

1 Like

Hi @Rosika
It works in my Debian 11
nevj@mary:~$ kate
bash: kate: command not found
NO THAT IS WRONG, SEE NEXT POST

but it is not there?
nevj@mary:~$ dpkg -l | grep command-not
nevj@mary:~$

will look further

Can you explain to a novice please - how do you do those cut and paste segments that come out greyed in your post? I can cut and paste, but as you can see above it just looks like plain text

Greetings for New Year
Neville

Hi again @Rosika
OK I needed to install command-not found
nevj@mary:~$ su
Password:
root@mary:/home/nevj# apt-get install command-not-found
Reading package lists… Done

Setting up command-not-found (20.10.1-1) …
You need to run ‘update-command-not-found’ as root to update the cache.
Processing triggers for man-db (2.9.4-2) …
root@mary:/home/nevj#
root@mary:/home/nevj#
root@mary:/home/nevj# update-command-not-found
root@mary:/home/nevj# exit
exit
nevj@mary:~$
nevj@mary:~$
nevj@mary:~$ kate
bash: kate: command not found
nevj@mary:~$ dpkg -l command-not-found
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
++±=================-============-============-==================================>
ii command-not-found 20.10.1-1 all Suggest installation of packages i

So even when I install command-not -found it does nothing, but I do not get your errors
nevj@mary:~$ kate
bash: kate: command not found

Did you do the update-command-not-found bit, as superuser?

Mystery
Neville

1 Like

Third go @Rosika
I reboot and try again

nevj@mary:~$ kate
Could not find command-not-found database. Run ‘sudo apt update’ to populate it.
kate: command not found

So lets do an update
nevj@mary:~$ su
Password:
root@mary:/home/nevj# apt update
Hit:1 Index of /debian bullseye InRelease
…eading state information… Done
6 packages can be upgraded. Run ‘apt list --upgradable’ to see them.

I did the apt list and there was nothing related to command-not-found
root@mary:/home/nevj# apt-get upgrade

Processing triggers for mailcap (3.69) …
root@mary:/home/nevj# exit

Then try again

nevj@mary:~$ kate
Command ‘kate’ not found, but can be installed with:
apt install kate
Please ask your administrator.
nevj@mary:~$

So now it works.
I think your problems are to do with using apt. It seems to need more than one update to get this package configured. And maybe it needs a reboot ?
That update after the install seemed to fix things.

Regards
Neville

1 Like

My two bob’s worth :

installed on Ubuntu 20.04 and it also installed that python3 package too…

installed on Buster (Raspbian on a Pi4), but only the one package installed…

But it doesn’t work like yours does - i.e. if I try to run something that doesn’t exist, it just barfs on it :

╭─x@tethys ~  
╰─➤  apt search command-not-found                                                                                                                           127 ↵
Sorting... Done
Full Text Search... Done
command-not-found/focal-updates,focal-updates,now 20.04.5 all [installed]
  Suggest installation of packages in interactive bash sessions

packagekit-command-not-found/focal-updates,focal-security 1.1.13-2ubuntu1.1 amd64
  Offer to install missing programs automatically

python3-commandnotfound/focal-updates,focal-updates,now 20.04.5 all [installed,automatic]
  Python 3 bindings for command-not-found.

╭─x@tethys ~  
╰─➤  kate
zsh: command not found: kate
╭─x@tethys ~  
╰─➤  edlin                                                                                                                                                  127 ↵
zsh: command not found: edlin

i.e. it never makes any helpful suggestions - sorry - can’t be of much help to you …

(note - same result on Ubuntu 20.04 and Raspbian Buster (Debian 10).

I’m thinking I may need to logout and in again??? But that doesn’t explain why it’s not helping me on Raspbian (Debian 10)… i.e. I logged out from SSH session and logged in again…

1 Like

Hi @daniel.m.tripp
Try a reboot ( not a logout) then another apt update.
This command-not-found thing seems to need to construct a database before it will work. An apt update seems to triggger it to make its database. That is weird?
I thought package systems like apt were supposed to have solved ‘dependency hell’
Neville

1 Like

I probably won’t do that anytime soon - only reboot when I really need to… “tethys” is my work laptop / desktop setup…

╭─x@tethys ~  
╰─➤  uptime
 11:21:45 up 41 days, 18:55,  2 users,  load average: 2.47, 2.39, 1.91

@daniel.m.tripp
OK. Reboot might not be necessary anyway.
Could you just try the
apt update
That might trigger it to create its database
Neville

1 Like

Just looked at

And it does not show lubuntu as an option but kubuntu

So had a look at

Where it suggests

suggests Lubuntu originally used the LXDE desktop, but moved to the LXQt desktop with the release of Lubuntu 18.10 in October 2018, due to the slow development of LXDE, losing support for GTK 2

Is that the problem ?

I don’t have a machine with lubuntu on today moved on to mint As no clients with that version any more.

May not be of help !

1 Like

You can do the following:

For single line output/code: enclose the words in backticks `command`.
For longer output, enclose the output with the <pre> </pre> HTML-tags.

1 Like

@Mina
Thank you, I have a practice here

I typed this. Will try a paste on PC

Neville

1 Like

Hi again to all of you, :wave:

thanks so much for your very detailed responses and for putting so much time and effort into helping me. It´s highly appreciated. :heart:

@nevj:

Hi Neville and thanks a lot.

I think @Mina provided a good solution in her comment. Thanks a lot, Mina. :+1:

The way I did it was that I posted the output of my commands using the “Preformatted text” option here in the forum (Ctrl+E).

Yes, the same with me (see my initial post).

Yes, I did. But to no avail (yesterday).

Well, I´ll be blessed. NOW it works. :kissing_smiling_eyes:

I could swear I did perform a reboot of my VM yesterday but I´m not so sure about it any longer.
Anyhow I switched off my main machine (and the VM of course) over night and today Debian/VM provides these results:

rosika2@debian ~> kate

Command 'kate' not found, but can be installed with:

sudo apt install kate

rosika2@debian ~> falkon

Command 'falkon' not found, but can be installed with:

sudo apt install falkon
[...]

Although python3-commandnotfound is still not installed on Debian command-not-found seems to work now. :blush:

I don´t know whether that did the trick (in addition to a cold start) but indeed I did perform

sudo apt update

in the beginning today and was surprised to learn the update needed over 36 MB of downloaded data (a rather unusually large amount for my Debian install).

Perhaps that had something to do with the “issue”. :question:

So thanks a lot again, Neville, for all this very useful input of yours. :heart:

@daniel.m.tripp:

Hi Daniel,

Yes, that´s the one thing I don´t understand. In the Debian repository there doesn´t even seem to be an installation candidate for that.

But as it turned out command-not-found works now (without that python3-package). :blush:

Hmm, what a funny behaviour in/of different distros.

Thanks anyway for yor help, Daniel :heart:

@callpaul.eu:

Hi Paul and thanks so much,

Well, I don´t think so as my main system (i.e. host) is Lubuntu whereas Debian (i.e. guest) is running in a VM.
In Lubuntu everything´s been working as expected from the beginning.
It´s just Debian which was struggling to get things working the way they should be.

But I´ve got it wotking now (see above).
Thanks a lot for looking up all the stuff on Lubuntu. That´s really kind of you. :heart:

Many greetings

@Mina:

Thanks a lot for your help and clarification as well. It´s very much appreciated. :heart:

Greetings to all of you from Rosika :slightly_smiling_face:

2 Likes

Hi @Rosika,
Well you really put some work into that reply
Great to hear you got it to work in Debian. I think the command-not-found package in Debian IS the python3 version, Debian have just renamed the package. They do that often.
The 36Mb… I dont know but may be something to do with its database.
Solved, thanks to all
Neville

1 Like

Hi Neville, :wave:

sorry I couldn´t reply earlier.

I see. Thanks for the additional info. That´s really good to know. :+1:

That´s what I was thinking as well.

Thanks again for your help.

Many greetings.
Rosika :slightly_smiling_face:

1 Like