You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[root@nixos:/etc/nixos]# command-not-found foobar
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 12.
cannot open database `/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' at /run/current-system/sw/bin/command-not-found line 12.
After quick googling I've found some email from 2013 suggesting that "you'll need to add the nixos-unstable channel as root". But isn't that so by default? I couldn't find "programs.sqlite" on github in the "nixos-unstable" branch anyway. If that email is correct, what exact steps one has to do to resolve this? As I still couldn't find out from searching the "channel" keyword in NixOS manual, being a NixOS newbie. Could the instructions at least be printed explicitly by the command-not-found Perl script instead of this cryptic message, if not baked in the nix-expression as an explicit dependency?
Maybe this info could be added in the manual then? Kinda "for some [which?] commands, sudo nix-channel --update is needed as it rebuilds [some internal stuff]"?
I have no /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite, adding a channel as root and sudo nix-channel --update does not generate one.
when I add a channel 15.09, I have the database in /nix/var/nix/profiles/per-user/root/channels/nixos-15.09/programs.sqlite (while command-not-found is looking for .... /nixos/...)
@nrolland: nix-channel adds pairs: URL and name that you choose independently. Currently command-not-found searches only for channel that you called nixos which is what you get on NixOS by default for the system channel.
I'm getting this weird behavior where the programs.sqlite file is found on an user's profile that is not root (vagrant in my case) how can I fix this scenario?
It looks like nix-channel stopped creating programs.sqlite a couple generations ago:
$ find -L /nix/var/nix/profiles/per-user -name "programs.sqlite"
/nix/var/nix/profiles/per-user/root/channels-4-link/nixos/programs.sqlite
/nix/var/nix/profiles/per-user/root/channels-5-link/nixos/programs.sqlite
/nix/var/nix/profiles/per-user/root/channels-6-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-7-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-7-link/nixos'.
/nix/var/nix/profiles/per-user/root/channels-7-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-13-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-13-link/nixos'.
/nix/var/nix/profiles/per-user/root/channels-13-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-14-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-14-link/nixos'.
/nix/var/nix/profiles/per-user/root/channels-14-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-15-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-15-link/nixos'.
/nix/var/nix/profiles/per-user/root/channels-15-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-16-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-16-link/nixos'.
/nix/var/nix/profiles/per-user/root/channels-16-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-17-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-17-link/nixos'.
/nix/var/nix/profiles/per-user/root/channels-17-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-18-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-18-link/nixos'.
/nix/var/nix/profiles/per-user/root/channels-18-link/nixos/programs.sqlite
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-19-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-19-link/nixos'.
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels-20-link/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels-20-link/nixos'.
find: File system loop detected; `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' is part of the same file system loop as `/nix/var/nix/profiles/per-user/root/channels/nixos'.
$ ls /nix/var/nix/profiles/per-user/root/
channels channels-11-link channels-13-link channels-15-link channels-17-link channels-19-link channels-20-link channels-3-link channels-5-link channels-7-link channels-9-link
channels-10-link channels-12-link channels-14-link channels-16-link channels-18-link channels-1-link channels-2-link channels-4-link channels-6-link channels-8-link
It doesn't appear nix-channel creates programs.sqlite. In fact, after greping in nixpkgs, nix and hydra, I don't see where programs.sqlite is ever created... I'm pretty stumped.
Closing this as it works again. The requirements aren't documented because Nix wrapps the binary with everything needed, but channels didn't ship programs.sqlite as the generation was disabled. We should probably bail out with a clearer message or just fail silently.
Activity
vcunat commentedon Dec 31, 2015
I think you need at least
$ sudo nix-channel --update. The path above certainly does exist when the channels are setup according to the manual.It's generated from binaries and has no place in source repositories.
Add some channel as root (and call it "nixos") or check it is so already, and update it. IMO
$ man nix-channelis a good source of how to do it.akavel commentedon Dec 31, 2015
Maybe this info could be added in the manual then? Kinda "for some [which?] commands,
sudo nix-channel --updateis needed as it rebuilds [some internal stuff]"?[-]command-not-found not working?[/-][+]command-not-found requirements aren't documented[/+]vcunat commentedon Dec 31, 2015
Yes, perhaps.
domenkozar commentedon Feb 25, 2016
Sadly this doesn't work when
nix.nixPathis declared as channel doesn't exist. Shouldcommand-not-foundevaluate nix to get the path? cc @edolstranrolland commentedon Mar 2, 2016
I have no
/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite, adding a channel as root andsudo nix-channel --updatedoes not generate one.when I add a channel 15.09, I have the database in
/nix/var/nix/profiles/per-user/root/channels/nixos-15.09/programs.sqlite(while command-not-found is looking for.... /nixos/...)is there a specific command to get around that ?
vcunat commentedon Mar 2, 2016
@nrolland: nix-channel adds pairs: URL and name that you choose independently. Currently
command-not-foundsearches only for channel that you callednixoswhich is what you get on NixOS by default for the system channel.roman commentedon Mar 14, 2016
I'm getting this weird behavior where the
programs.sqlitefile is found on an user's profile that is not root (vagrant in my case) how can I fix this scenario?cstrahan commentedon Mar 17, 2016
As of my last
sudo nix-channel --update, I no longer have/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite...cstrahan commentedon Mar 17, 2016
cstrahan commentedon Mar 17, 2016
It looks like
nix-channelstopped creatingprograms.sqlitea couple generations ago:It's missing in my generation 19 and 20.
cstrahan commentedon Mar 17, 2016
It doesn't appear
nix-channelcreatesprograms.sqlite. In fact, after greping innixpkgs,nixandhydra, I don't see whereprograms.sqliteis ever created... I'm pretty stumped.vcunat commentedon Mar 17, 2016
It can't be created locally. It should be contained in the downloaded
nixexprs.tar.xz, but I see it isn't anymore. NixOS/nixos-channel-scripts@f7beae7#diff-682bf482f6dd273f1c3c49afd99b4660R122vcunat commentedon Mar 17, 2016
Aha, there's an issue about it: NixOS/nixos-channel-scripts#4.
domenkozar commentedon Sep 20, 2016
Closing this as it works again. The requirements aren't documented because Nix wrapps the binary with everything needed, but channels didn't ship programs.sqlite as the generation was disabled. We should probably bail out with a clearer message or just fail silently.
sbourdeauducq commentedon Mar 29, 2021
Is there a solution now for using
nix.nixPathin combination withcommand-not-found?domenkozar commentedon Mar 29, 2021
See #39789 for a possible way forward.