nix-community / comma

Comma runs software without installing it. [maintainers=@Artturin,@burke,@DavHau]
MIT License
1.14k stars 50 forks source link

only warn about non-existent database if nix-locate fails #44

Closed lilyinstarlight closed 1 year ago

lilyinstarlight commented 1 year ago

When using a non-standard database location for nix-index (e.g. via the NixOS module in the github:Mic92/nix-index-database flake), comma warns that the database is non-existent even though it does exist and nix-locate works fine

This changes the logic so that it only checks if the database exists when the nix-locate command fails

The warning I receive without this patch ``` [I] lily@bina ~> , node Warning: Nix-index database does not exist, try updating with `--update`. Welcome to Node.js v18.12.1. ```
The output with this patch when nix-locate fails to find database ``` [I] lily@bina ~> , node Warning: Nix-index database does not exist, try updating with `comma --update`. nix-locate failed with: error: reading from the database at '/home/lily/.cache/nix-index/files' failed. This may be caused by a corrupt or missing database, try (re)running `nix-index` to generate the database. If the error persists please file a bug report at https://github.com/bennofs/nix-index. caused by: No such file or directory (os error 2) ```
The output with this patch when nix-locate succeeds ``` [I] lily@bina ~> , node Welcome to Node.js v18.12.1. ```
The output with this patch for an unknown binary ``` [I] lily@bina ~> , nonexistentbin No executable `nonexistentbin` found in nix-index database. ```
Artturin commented 1 year ago

Thanks