NixOS/nix

nix path-info --json always return with exit code 0 contradicting docs

Open

#10.886 aperta il 10 giu 2024

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)C++ (1293 fork)batch import
buggood first issuenew-cli

Metriche repository

Star
 (9803 star)
Metriche merge PR
 (Merge medio 4g 12h) (86 PR mergiate in 30 g)

Descrizione

Describe the bug

From the docs:

          Warning

         Note that nix path-info does not build or substitute the installables you specify. Thus, if the corresponding store paths don’t already exist, this command will
        fail. You can use nix build to ensure that they exist.

Steps To Reproduce

nix path-info .#derivation-didnt-build

returns

error: path '/nix/store/qd2prbj1wjbf0r816s60ps15i7hw5l90-nixos-system-unnamed-24.05.20240530.d24e7fd' is not valid
$ echo $?
1

However

nix path-info .#derivation-didnt-build --json

returns

{"/nix/store/qd2prbj1wjbf0r816s60ps15i7hw5l90-nixos-system-unnamed-24.05.20240530.d24e7fd":null}% 
$ echo $?
0

Expected behavior

nix path-info --json

should return non-zero exit code if derivation isnt built

nix-env --version output

Additional context

I'm using this to check if a derivation is in cache but this command silently broke broke as I added --json

if ! nix path-info  --eval-store auto --store s3://mybucket ; then
  nix copy --eval-store --auto --to s3://mybucket  
fi

Priorities

Add :+1: to issues you find important.

Guida contributor