[command-not-found]: don't report bad database
I didn't think it did this before, but if you don't have a nix-index created, it reports an error:
error: reading from the database at '/Users/baumatth/.cache/nix-index/files' failed.
This may be caused by a corrupt or missing database, try (re)running `nix-index`` to generate the database.
If the error persists please file a bug report at https://github.com/bennofs/nix-index.
caused by: database corrupt, frcode error: incomplete frame
hello: command not found
Ideally command-not-found would be invisible in these cases. We either need a "quiet" option from nix-locate or just redirect stderr to /dev/null.
I am not sure I agree with your goal that command-not-found should be invisible. If it was truly invisible, then how are users going to know they have to create a database?
caused by: database corrupt, frcode error: incomplete frame
Is your database really missing? This sounds more like a corrupt (for example, did you interrupt nix-index while it was running? we should perhaps make updating the database atomic) database to me.
I think it was in progress at the time so that may have been causing it (running command in a new shell).
I guess the hope is that command-not-found could be opt in if you don't have the database. It is run after each bash command so we don't want it to be too obnoxious. If you wonder why you can't get suggestions, you can just run nix-index to generate them.
This is the output for a missing database on 0.1.2:
[nix-shell:~]$ /nix/store/ci9b59823i7kpl0qm4hivk9yn93nns58-nix-index-0.1.2/bin/nix-locate --minimal --no-group --type x --type s --top-level --whole-name --at-root /bin/firefox
error: reading from the database at '/home/wmertens/.cache/nix-index/files' failed.
This may be caused by a corrupt or missing database, try (re)running `nix-index`` to generate the database.
If the error persists please file a bug report at https://github.com/bennofs/nix-index.
caused by: No such file or directory (os error 2)
If the DB is missing, I think command-not-found.sh should print
xxx: command not found.
If you would like to get suggestions for packages, run `nix-index`
If the DB is corrupt, it should say
xxx: command not found.
nix-index DB is corrupt! Please run nix-index to fix this