Skip to content

command-not-found requirements aren't documented #12044

Closed

Description

@akavel
[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?

Activity

  1. vcunat commented on Dec 31, 2015

    @vcunat
    Member

    "you'll need to add the nixos-unstable channel as root". But isn't that so by default?

    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.

    I couldn't find "programs.sqlite" on github in the "nixos-unstable" branch anyway.

    It's generated from binaries and has no place in source repositories.

    If that email is correct, what exact steps one has to do to resolve this?

    Add some channel as root (and call it "nixos") or check it is so already, and update it. IMO $ man nix-channel is a good source of how to do it.

  2. akavel commented on Dec 31, 2015

    @akavel
    ContributorAuthor

    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]"?

  3. added
    9.needs: documentation
    on Dec 31, 2015
  4. changed the title [-]command-not-found not working?[/-] [+]command-not-found requirements aren't documented[/+] on Dec 31, 2015
  5. added
    0.kind: enhancement
    on Dec 31, 2015
  6. vcunat commented on Dec 31, 2015

    @vcunat
    Member

    Yes, perhaps.

  7. domenkozar commented on Feb 25, 2016

    @domenkozar
    Member

    Sadly this doesn't work when nix.nixPath is declared as channel doesn't exist. Should command-not-found evaluate nix to get the path? cc @edolstra

  8. nrolland commented on Mar 2, 2016

    @nrolland

    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/...)

    is there a specific command to get around that ?

  9. vcunat commented on Mar 2, 2016

    @vcunat
    Member

    @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.

  10. roman commented on Mar 14, 2016

    @roman
    Contributor

    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?

  11. cstrahan commented on Mar 17, 2016

    @cstrahan
    Contributor

    As of my last sudo nix-channel --update, I no longer have /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite...

  12. cstrahan commented on Mar 17, 2016

    @cstrahan
    Contributor
    $ sudo nix-channel --list
    nixos https://nixos.org/channels/nixos-unstable
    
  13. cstrahan commented on Mar 17, 2016

    @cstrahan
    Contributor

    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's missing in my generation 19 and 20.

  14. cstrahan commented on Mar 17, 2016

    @cstrahan
    Contributor

    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.

  15. vcunat commented on Mar 17, 2016

    @vcunat
    Member

    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-682bf482f6dd273f1c3c49afd99b4660R122

  16. vcunat commented on Mar 17, 2016

    @vcunat
    Member

    Aha, there's an issue about it: NixOS/nixos-channel-scripts#4.

  17. domenkozar commented on Sep 20, 2016

    @domenkozar
    Member

    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.

  18. sbourdeauducq commented on Mar 29, 2021

    @sbourdeauducq
    Contributor

    Sadly this doesn't work when nix.nixPath is declared as channel doesn't exist. Should command-not-found evaluate nix to get the path?

    Is there a solution now for using nix.nixPath in combination with command-not-found?

  19. domenkozar commented on Mar 29, 2021

    @domenkozar
    Member

    See #39789 for a possible way forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: enhancement9.needs: documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions