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

Nix's master branch has broken nix-build exit codes #4813

Open
grahamc opened this issue May 16, 2021 · 5 comments
Open

Nix's master branch has broken nix-build exit codes #4813

grahamc opened this issue May 16, 2021 · 5 comments
Labels

Comments

@grahamc
Copy link
Member

grahamc commented May 16, 2021

Describe the bug

nix-build should exit based on how the build failed. For example, from the docs:

Special exit codes:

    100
    Generic build failure, the builder process returned with a non-zero exit code.

    101
    Build timeout, the build was aborted because it did not complete within the specified timeout.

    102
    Hash mismatch, the build output was rejected because it does not match the outputHash attribute of the derivation.

    104
    Not deterministic, the build succeeded in check mode but the resulting output is not binary reproducable.

However, this is currently broken:

[grahamc@hyperchicken:~/projects/github.com/NixOS/nixpkgs]$ nix-build /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv ; echo $?
this derivation will be built:
  /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv
building '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv'...

trying https://github.com/mpv-player/mpv/commit/7c4465cefb27d4e0d07535d368febdf77b579566.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3553  100  3553    0     0  16919      0 --:--:-- --:--:-- --:--:-- 16919
error: hash mismatch in fixed-output derivation '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv':
         specified: sha256-PX8fPds1v2tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
            got:    sha256-PX8fPds1v3tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
1
[grahamc@hyperchicken:~/projects/github.com/NixOS/nixpkgs]$ nix-store --realize /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv; echo $?
this derivation will be built:
  /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv
building '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv'...

trying https://github.com/mpv-player/mpv/commit/7c4465cefb27d4e0d07535d368febdf77b579566.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3553  100  3553    0     0  36628      0 --:--:-- --:--:-- --:--:-- 36628
error: hash mismatch in fixed-output derivation '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv':
         specified: sha256-PX8fPds1v2tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
            got:    sha256-PX8fPds1v3tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
1

Steps To Reproduce

  1. Create a fixed output derivation which has the wrong hash
  2. Try to build it
  3. Note that the exit code is wrong.

Expected behavior

Nix should exit with the documented exit codes.

nix-env --version output

nix-env (Nix) 2.4pre20210514_de9e43c

Additional context

NixOS unstable

@grahamc grahamc added the bug label May 16, 2021
@grahamc
Copy link
Member Author

grahamc commented May 16, 2021

This appears to be broken when talking to the daemon, and not broken when using nix-build as root.

@thufschmitt
Copy link
Member

It seems to be due to c43e882f54#diff-9338f330e24f13e71e33fcd53698bb563f916fb823331f0484c1a1674974e896R928-R934 : With a new-enough daemon, the communication of the exceptions from the daemon to the client now uses an overload of operator << and readError, but it looks like these don’t transmit the status field which is the one used to set the return code for the executable (here)

@grahamc
Copy link
Member Author

grahamc commented May 16, 2021

I wonder if it would be easier to keep these working if the client always transmitted data to the daemon and back using data objects, serialized or not like protobufs or something -- regardless of if it is actually talking to the daemon or not.

@thufschmitt
Copy link
Member

I wonder if it would be easier to keep these working if the client always transmitted data to the daemon and back using data objects, serialized or not like protobufs or something -- regardless of if it is actually talking to the daemon or not.

That could greatly help, yes. I think it might have some performance implications on some-cases because bypassing the daemon can prevent from having to send big things like Nar archives down the wire − IIRC the hydra runners run in daemonless mode just for that. But that could be mitigated by special-casing some operations (the same way Nix occasionnally directly reads stuff from the store even when using the daemon).

Now of course that’s quite a big refactoring to make, so… 🙃

@stale
Copy link

stale bot commented Nov 16, 2021

I marked this as stale due to inactivity. → More info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants