CommandNotFoundMagic

Differences between revisions 3 and 13 (spanning 10 versions)
Revision 3 as of 2005-11-05 20:50:39
Size: 1975
Editor: 209
Comment: typo
Revision 13 as of 2008-08-06 16:20:46
Size: 2667
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
 * '''Launchpad Entry''': https://launchpad.net/distros/ubuntu/+spec/foo
 * '''Created''': [[Date(2005-11-05T20:45:55Z)]] by MichaelVogt
 * '''Contributors''': MichaelVogt
 * '''Packages affected''':

##(see the SpecSpec for an explanation)

 * '''Launchpad Entry''': https://launchpad.net/distros/ubuntu/+spec/foo
 * '''Created''': [[Date(2005-11-04T23:14:14Z)]] by MichaelVogt
 * '''Launchpad Entry''': https://launchpad.net/distros/ubuntu/+spec/command-not-found-magic
 * '''Created''': <<Date(2005-11-04T23:14:14Z)>> by MichaelVogt
Line 22: Line 15:
== Rational == == Rationale ==
Line 24: Line 17:
Because ubuntu ships only with a single CD some commands that power-users expect are not installed (e.g. gcc, make). Because Ubuntu ships only with a single CD some commands that power-users expect are not installed (e.g. gcc, make).
Line 30: Line 23:
 dialog saying that installing the mentioned package is needed.  message saying that installing the mentioned package is needed.
Line 41: Line 34:
 * from a "by-hand" file to include additonal stuff (like acroread)  * from a "by-hand" file to include additional stuff (like acroread)
Line 47: Line 40:
The command_not_found handler is in bash, no code for the python script has
been written yet..
Code is available in http://ubuntu.suxx.pl/2006--1/bzr-archive/command-not-found--main/ and http://people.ubuntu.com/~mvo/bzr/command-not-found/mvo

A initial implementation is available in edgy. A version that also displays the component that is required for the package and that fixes some filtering problem is available as 0.2.0 in edgy.

== Problems ==

The real evil for this spec is the "update-alternatives" command. A common application like "vi" is not shipped by the various packages as "vi" but as "vim","nvi", etc and updated via update-alternatives to "vi" in the postinst scripts. This needs to be evaluated as well. The problem is that some packages embed the call in bash code with "update-alternative $pkg" (e.g. the emacs postinst), making it hard to automatically parse the code.

== Comments ==

It could suggest another spelling to the command, using a simple Spell Corrector:
http://www.peterbe.com/plog/spellcorrector
http://www.norvig.com/spell-correct.html

----
CategorySpec

Summary

The "command not found" message is not very helpful. If e.g. the unzip command is not found but it's available in a package, it would be very interesting if the system could tell that the command is currently not available, but installing a package would provide it.

Rationale

Because Ubuntu ships only with a single CD some commands that power-users expect are not installed (e.g. gcc, make).

Use cases

  • John sees a tutorial of how to unzip a package using the unzip command, and tries to follow it. The needed package is not installed, so he gets a message saying that installing the mentioned package is needed.

Design

Bash has a "command_not_found" handler that is called in the interactive mode when a command is not found. The first argument is the command that is not found. We hook a custom python script into it that has a database (gdbm or similar) with the available commands as keys and some information (like a list of packages it is in) as value. This lookup needs to be fast. This information is assembled from various sources:

  • from the Content-$arch file
  • from a "by-hand" file to include additional stuff (like acroread)
  • a mirror with deb that are scanned for update-alternatives commands in

    • postinst

Implementation

Code is available in http://ubuntu.suxx.pl/2006--1/bzr-archive/command-not-found--main/ and http://people.ubuntu.com/~mvo/bzr/command-not-found/mvo

A initial implementation is available in edgy. A version that also displays the component that is required for the package and that fixes some filtering problem is available as 0.2.0 in edgy.

Problems

The real evil for this spec is the "update-alternatives" command. A common application like "vi" is not shipped by the various packages as "vi" but as "vim","nvi", etc and updated via update-alternatives to "vi" in the postinst scripts. This needs to be evaluated as well. The problem is that some packages embed the call in bash code with "update-alternative $pkg" (e.g. the emacs postinst), making it hard to automatically parse the code.

Comments

It could suggest another spelling to the command, using a simple Spell Corrector: http://www.peterbe.com/plog/spellcorrector http://www.norvig.com/spell-correct.html


CategorySpec

CommandNotFoundMagic (last edited 2008-08-06 16:20:46 by localhost)