Error when typing commands in terminal

I get this error whenever i type a command that doesn’t exist:

Baryon@serverless: btop

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-systen/su/bin/command-not-found line 13.

Not sure if there are more “official” docs on it (maybe something on wiki ?), but last time I checked this describes problem/solutions pretty well:
https://blog.nobbz.dev/2023-02-27-nixos-flakes-command-not-found/

You can also use nix-index for that (with nix-index-database if you do not want to generate cache yourself):

1 Like

I’m not having issue in the pre-installed packages and software, only problem I do have is with when i write a command of a package that is not installed,
expected output:

[nyxar@nixos ~]$ clang
The program 'clang' is not in your PATH. It is provided by several packages.
You can make it available in an ephemeral shell by typing one of the following:
  nix-shell -p clang
  nix-shell -p clang_12
  nix-shell -p clang_13
     ...

the output i got:

[baryon@🌐 serverless .config/fish]$ clang
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.

That is what programs.command-not-found.enable that is enabled by default does.
Checks precomputed db from root channel and outputs that “expected output”.
Assuming you do not use channels (you use flakes or something else instead) it won’t be able to find that db.
Your options:

  1. disable it by adding programs.command-not-found.enable = false; to your config.
  2. If you still want it, do either of these:
2 Likes

No I don’t use flakes, and this feature should come with the system by default, also, nix-index doesn’t work at all, once I reboot, everything related to nix-index is deleted
(i guess i should not that i’m used the minimal installer to install this nios version)

Please run sudo nix-channel --list and nix-channel --list as your user

sudo nix-channel --list output is nixos https://nixos.org/channels/nixos-24.05
the other one output nothing as expected
i can install packages and all that so i know it’s working