28

Often when I mistype a command such as ls (e.g. I hit ENTER before I type 's') there is a long (~2s) delay after the terminal displays:

bash: l: command not found...

I can understand the reasons for a similar delay after an incorrect password is entered, per Why is there a big delay after entering a wrong password?. But why delay after an unrecognized command? Does FAIL_DELAY in /etc/login.defs affect this also?

calebds
  • 585
  • 9
    Maybe Fedora is now also using that horrible Ubuntu misfeature that tells you "This program is not installed, to install it, type ..."? The delay is then caused by searching the database of all installable packages. Try calling psql (part of PostgreSQL), which is probably not installed by default, but is hopefully in the repositories. – Ulrich Schwarz Nov 29 '11 at 18:51
  • What does echo "$PROMPT_COMMAND" output? – rozcietrzewiacz Nov 29 '11 at 19:28
  • echo "$PROMPT_COMMAND": printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}" – calebds Nov 29 '11 at 19:48
  • what echo $PATH prints ? your system is check there each time you hit the return key. – Hanan Nov 29 '11 at 21:22

4 Answers4

24

after some research I have found this:

  • try to uninstall the command-not-found package with $>yum remove command-not-found then install it again with >$yum install command-not-found (just in case you have that package installed on your system).

if that doesn't help try:

  • add this to your ~/.bashrc file:

    unset command_not_found_handle

peterh
  • 9,731
Hanan
  • 5,771
24

I found that the best solution, at least on Fedora, is to modify the configuration file
/etc/PackageKit/CommandNotFound.conf

as the biggest delay comes from the search for packages to install, if you modify SoftwareSourceSearch=true in SoftwareSourceSearch=false

the delay is almost 0 and you still get warned about misspellings, which can be useful.

GiP
  • 241
4

Fedora uses something similar.

If you want to just remove this feature use:

yum remove PackageKit-command-not-found
  • Follow up: I forgot to mention if you remove this package you will get an error message:
    bash: /usr/libexec/pk-command-not-found: No such file or directory
    To fix this create the file after removeing the package, /usr/libexec/pk-command-not-found with the following:
    #!/bin/sh echo "Command not found: $1"
    This will print:
    Command not found: fail-command
    –  Mar 21 '12 at 05:31
1

In my case it's because of some known proxy bug in /usr/libexec/pk-command-not-found

Failed to search for file: cannot update repo 'updates':
Cannot prepare internal mirrorlist:
Curl error (28): Timeout was reached for https://mirrors.fedoraproject.org/metalink?repo=updates-released-f28&arch=x86_64 
[Connection timed out after 30002 milliseconds]

My proxy configuration is correct because downloading the exact same URL with a bare curl command succeeds instantly.

I checked the pk-command-not-found process does have the proxy configuration:

tr  '\0' '\n' < /proc/$(pgrep -f pk-command-not-found)/environ | grep -i proxy

However it does not use it for some unknown reason.

https://bugzilla.redhat.com/show_bug.cgi?id=1553368

MarcH
  • 271