I’m seeing this in 21.11, and none of the above suggestions appear to work for me.
My root user appears to have the correct channel:
$ id
uid=0(root) gid=0(root) groups=0(root)
$ nix-channel --list
nixos https://nixos.org/channels/nixos-21.11
But command-not-found
still can’t find the database:
$ 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.
This error message seems reasonable, since the programs.sqlite
database really doesn’t exist:
$ ls -lah /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite
ls: cannot access '/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite': No such file or directory
$ ls -lah /nix/var/nix/profiles/per-user/root/channels/nixos/
total 88K
dr-xr-xr-x 8 root root 4.0K Jan 1 1970 .
dr-xr-xr-x 3 root root 4.0K Jan 1 1970 ..
-r--r--r-- 1 root root 4.9K Jan 1 1970 CONTRIBUTING.md
-r--r--r-- 1 root root 1.1K Jan 1 1970 COPYING
-r--r--r-- 1 root root 971 Jan 1 1970 default.nix
dr-xr-xr-x 11 root root 4.0K Jan 1 1970 doc
-r--r--r-- 1 root root 2.3K Jan 1 1970 .editorconfig
-r--r--r-- 1 root root 3.3K Jan 1 1970 flake.nix
-r--r--r-- 1 root root 598 Jan 1 1970 .gitattributes
dr-xr-xr-x 4 root root 4.0K Jan 1 1970 .github
-r--r--r-- 1 root root 344 Jan 1 1970 .gitignore
-r--r--r-- 1 root root 40 Jan 1 1970 .git-revision
dr-xr-xr-x 4 root root 4.0K Jan 1 1970 lib
dr-xr-xr-x 3 root root 4.0K Jan 1 1970 maintainers
dr-xr-xr-x 7 root root 4.0K Jan 1 1970 nixos
lrwxrwxrwx 1 root root 1 Jan 1 1970 nixpkgs -> .
dr-xr-xr-x 18 root root 4.0K Jan 1 1970 pkgs
-r--r--r-- 1 root root 5.8K Jan 1 1970 README.md
-r--r--r-- 1 root root 20 Jan 1 1970 svn-revision
-r--r--r-- 1 root root 5 Jan 1 1970 .version
-r--r--r-- 1 root root 19 Jan 1 1970 .version-suffix
Any idea what could be going on here?
edit: I should add my nixos commit:
$ cat /nix/var/nix/profiles/per-user/root/channels/nixos/.git-revision
1bd4bbd49bef217a3d1adea43498270d6e779d65