command-not-found not working because programs.sqlite is missing

Viewed 1724

I'm on the unstable nix channel:

# nix-channel --list
nixos https://nixos.org/channels/nixos-unstable
# nix-channel --update
downloading Nix expressions from ‘https://nixos.org/releases/nixos/unstable/nixos-16.09pre78848.9549257//nixexprs.tar.xz’...
downloading ‘https://nixos.org/releases/nixos/unstable/nixos-16.09pre78848.9549257//nixexprs.tar.xz’... [ [6192/6921 KiB, 6143.1 KiB/s]
unpacking channels...

For some reason, command-not-found doesn't work:

$ command-not-found
/home/fabian command-not-found 
DBI connect('dbname=/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite','',...) failed: unable to open database file at /run/current-system/sw/bin/command-not-found line 13.
cannot open database `/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' at /run/current-system/sw/bin/command-not-found line 13.

Indeed, /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite doesn't exist. What could be the reason for this?

2 Answers

FWIW, it seems nixos-install doesn't properly generate programs.sqlite.

I was seeing the same error on a fresh 17.03 install, even though it's working on other systems I have that are also on 17.03.

Manually running nix-channel --update was all that was needed to fix it for me. (I didn't run nixos-rebuild or anything that would have changed the versions of command-not-found.)

Related