NixOS/nix

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

Aberta

#10.886 aberto em 10 de jun. de 2024

 (1 comentário) (0 reação) (0 responsável)C++ (1.293 forks)batch import
buggood first issuenew-cli

Métricas do repositório

Stars
 (9.803 estrelas)
Métricas de merge de PR
 (Mesclagem média 7d 11h) (83 fundiu PRs em 30d)

Description

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.

Guia do colaborador