Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comma prints warning if you have a ~/.cache/nix-index/files #92

Closed
hraban opened this issue Feb 10, 2024 · 7 comments
Closed

Comma prints warning if you have a ~/.cache/nix-index/files #92

hraban opened this issue Feb 10, 2024 · 7 comments

Comments

@hraban
Copy link

hraban commented Feb 10, 2024

I used to index packages locally on my machine so I had a stale index lying around. This package's nix-locate ignored it, but comma gave a warning:

$ , hello
Warning: Nix-index database is older than 30 days, either obtain a prebuilt database from https://github.com/Mic92/nix-index-database or try updating with `nix run 'nixpkgs#nix-index' --extra-experimental-features 'nix-command flakes'`.
Hello, world!
$ which ,
/run/current-system/sw/bin/,
$ ls -l /run/current-system/sw/bin/,
lrwxr-xr-x  1 root  wheel  69 Dec 31  1969 /run/current-system/sw/bin/, -> /nix/store/0hrizv0a95g4rfhsg679506l976nb9xx-comma-with-db-1.7.1/bin/,
$ cat /run/current-system/sw/bin/,
#! /nix/store/0wzb184kckhmggq1nlvy5xk6rykp0jl1-bash-5.2-p21/bin/bash -e
export NIX_INDEX_DATABASE='/nix/store/0hrizv0a95g4rfhsg679506l976nb9xx-comma-with-db-1.7.1/share/cache/nix-index'
exec "/nix/store/25a77mrqczxqmsq6mrnbgqm25ra2lhyi-comma-1.7.1/bin/,"  "$@"
$ nix-locate -r '/bin/hello$'
haskellPackages.hello.out                    10,163,408 x /nix/store/y21zcncgd157xbb3bdnwqzai98h4x08r-hello-1.0.0.2/bin/hello
mbedtls.out                                     149,312 x /nix/store/s5zjq6hibgqbjx5xbcr50c5zkgrq8yl5-mbedtls-3.5.2/bin/hello
mbedtls_2.out                                    74,096 x /nix/store/1572c3fk6wvz0sd9rpahl9zg6iqjikrw-mbedtls-2.28.7/bin/hello
hello.out                                        82,256 x /nix/store/84ljc7x3vdlwnkmg3j65npz3dix188qq-hello-2.12.1/bin/hello
fltk14.bin                                            0 s /nix/store/y2xyqycdkhpqcz5paq3rwwksqlqibjjs-fltk-1.4.x-2021-12-21-bin/bin/hello
fltk.bin                                              0 s /nix/store/1i714kkqb4xz0r5vw4ggpqczfs2p562m-fltk-1.3.8-bin/bin/hello
$ # N.B.: no warning about nix DB being out of date
$ which nix-locate
/run/current-system/sw/bin/nix-locate
$ cat /run/current-system/sw/bin/nix-locate
#! /nix/store/0wzb184kckhmggq1nlvy5xk6rykp0jl1-bash-5.2-p21/bin/bash -e
export NIX_INDEX_DATABASE='/nix/store/wzc1ci0clv2lrp8nif9mr1479smz98as-nix-index-with-db-0.1.7/share/cache/nix-index'
exec "/nix/store/dx007v5i4jlm7mbx5rbrq8dmfxibgn96-nix-index-0.1.7/bin/nix-locate"  "$@"
$ ls -l /nix/store/0hrizv0a95g4rfhsg679506l976nb9xx-comma-with-db-1.7.1/share/cache/nix-index
total 0
lrwxr-xr-x  1 root  wheel  64 Dec 31  1969 files -> /nix/store/6cicbjx5q739a7x6xzklsclgcggc83rb-index-aarch64-darwin
$ ls -l /nix/store/wzc1ci0clv2lrp8nif9mr1479smz98as-nix-index-with-db-0.1.7/share/cache/nix-index
total 0
lrwxr-xr-x  1 root  wheel  64 Dec 31  1969 files -> /nix/store/6cicbjx5q739a7x6xzklsclgcggc83rb-index-aarch64-darwin
$ ls -lha ~/.cache/nix-index/files
-rw-r--r--@ 1 user  staff    31M Oct 17 13:02 /Users/user/.cache/nix-index/files
$ trash ~/.cache/nix-index/files
$ , hello
Hello, world!

Notice the warning after the first , hello, but none after the last.

@Mic92
Copy link
Member

Mic92 commented Mar 8, 2024

Ah. I saw this issue as well, but never investigated where it comes from.

@hraban
Copy link
Author

hraban commented Mar 8, 2024

NGL I ignored this warning for a long time until I accidentally figured it out 😂

@Mic92
Copy link
Member

Mic92 commented Mar 10, 2024

This is how we are currently wrapping things:

 export NIX_INDEX_DATABASE='/nix/store/4jscilyjg0vk8m21kw4blb9fb892b96v-comma-with-db-1.7.1/share/cache/nix-index'
 exec "/nix/store/cv9pya3qj1sqkxqlcj8qc7pqxmp8fc6h-comma-1.7.1/bin/,"  "$@" 

Comma should really prioritize NIX_INDEX_DATABASE over local files.

@Mic92
Copy link
Member

Mic92 commented Mar 10, 2024

Mhm. It's actually only nix-index that uses this variable. Is comma maybe wrapped with an old nix-index version that does use NIX_INDEX_DATABASE yet?

@Mic92
Copy link
Member

Mic92 commented Mar 10, 2024

Ah, but it's comma that prints the warning. It doesn't implement NIX_INDEX_DATABASE at all.

@Mic92
Copy link
Member

Mic92 commented Mar 10, 2024

Proper fix: nix-community/comma#73

@hraban
Copy link
Author

hraban commented Mar 10, 2024

I'm not sure I follow how a tool that doesn't touch the database would complain about its age but I believe you. 👍 :)

Artturin pushed a commit to nix-community/comma that referenced this issue Mar 12, 2024
@Mic92 Mic92 closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants