Home

command-not-found

April 6th, 2008 (10:28 pm)

I just installed the latest Ubuntu beta and I'm impressed. There's this command-not-found package that's as simple as fantastic. If you type a non-existent command, it tells you where to find it and how to install the relevant package:

$ emacs
The program 'emacs' can be found in the following packages:
 * emacs21-nox (You will have to enable component called 'universe')
 * emacs22
 * emacs-snapshot (You will have to enable component called 'universe')
 * e3 (You will have to enable component called 'universe')
 * emacs-snapshot-nox (You will have to enable component called 'universe')
 * emacs22-gtk (You will have to enable component called 'universe')
 * emacs21 (You will have to enable component called 'universe')
 * emacs22-nox
 * jove (You will have to enable component called 'universe')
Try: sudo apt-get install 
-su: emacs: command not found


I think it's just brilliant. This thing works with some versions of bash (using the command_not_found_handle() extension from Debian) and zsh (by fiddling with preexec() and precmd()). I don't know if it'll annoy me after a while but, right now, I love it.

Comments

Posted by: olive42 ([info]olive42)
Posted at: April 7th, 2008 07:15 am (UTC)

So this has the most direct effect of slowing you down everytime you mistype a command since it will do a lot of lookups and such for every command not in your path.

Also, it can break automated installers or Makefile in interesting ways. Ok you never compile Perl again these days (short of using non interesting alternative operating systems) but this is a very simple case where the Perl makefile searches some commands and expects them to be or not be there.

Have you checked the return code?
[This was my rant of the day]

Posted by: OB ([info]ob_v)
Posted at: April 7th, 2008 10:26 pm (UTC)

The return code is 127 (good). I'm not sure the lookups are that expensive, considering the size of the db files in /usr/share/command-not-found/programs.d/ (2 MB all in all, that will likely be cached somewhere in RAM very quickly).

Posted by: olive42 ([info]olive42)
Posted at: April 8th, 2008 06:42 am (UTC)

Oh "somewhere in RAM" :) But where?

Posted by: dbrane ([info]dbrane)
Posted at: April 7th, 2008 07:56 am (UTC)

You are one of those easily amused people, aren't you? In that case, 'apt-get install sl' :-).

Posted by: ((Anonymous))
Posted at: May 19th, 2008 08:30 am (UTC)
what about "enropy-not-found"?

Sounds nice. In the next beta, will they add a "entropy-not-found" command , in case (just in case) the random generator is broken? :-P

5 Read Comments