NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.93k stars 1.53k forks source link

How do I inspect build artifacts when a build fails? #6829

Closed doyougnu closed 2 years ago

doyougnu commented 2 years ago

Is your feature request related to a problem? Please describe.

and I want to inspect the *.rej files. Where are they? How can I do that? I see it suggests running nix log ... so let's do that:

╰─λ nix log /nix/store/dw46zk0xm1ippmlyc8cj97gp8w3mzgdc-clang-unstable-2022-07-07.drv                                                                                                                                                                                  1 (13.049s)
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/7bhp3454ncjk519ix5dq7ri58v1c8bhf-clang-src-unstable-2022-07-07
source root is clang-src-unstable-2022-07-07/clang
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
applying patch /nix/store/34zhl915l308dpa7v2786z3xgbvy6398-purity.patch
patching file lib/Driver/ToolChains/Gnu.cpp
Hunk #1 FAILED at 487.
1 out of 1 hunk FAILED -- saving rejects to file lib/Driver/ToolChains/Gnu.cpp.rej

Ok I see a nix-store path, lets check that:

╰─λ  ls /nix/store/7bhp3454ncjk519ix5dq7ri58v1c8bhf-clang-src-unstable-2022-07-07                                                                                                                                                                                       0 (0.001s)
clang/  cmake/

Ok great let's check the file:

╰─λ find /nix/store/7bhp3454ncjk519ix5dq7ri58v1c8bhf-clang-src-unstable-2022-07-07/ -name '*.rej' 
[I] ╭─doyougnu at 7thChamber in /home/doyougnu/programming/ghc.nix (master↑8 ✚3…1)
╰─λ  

Nothing.

Describe the solution you'd like Perhaps this is a documentation issue, but if it is I want documentation that says:

  1. Run a build ... nix build ....
  2. If it fails you can always check the working directory ...
  3. Or better yet, run nix log --something or nix develop --something which saves the working directory for inspection to /tmp/something

Describe alternatives you've considered I've considered doing cloning llvm manually just to inspect the patch error. But what is the point of using nix if I have to do this when I run into a build problem?

cole-h commented 2 years ago

Have you tried using the --keep-failed flag? After the build fails, it should output something along the lines of "keeping /tmp/....". Usually /tmp/drvname-0, I believe.

doyougnu commented 2 years ago

Yes this is exactly what I was missing. I cannot find a reference to this flag in either the man page for nix build or the nix manual. Am I missing something or is this just undocumented?

cole-h commented 2 years ago

nix --help | grep keep-failed shows it for me.

doyougnu commented 2 years ago

Closing. Thanks for the help @cole-h