I have a package that takes a non-trivial amount of time to build.
I want to inspect the state of the directory in which it is built between some phases.
How do I do that without running guix build
again and again with some print commands strewn in between phases?
Got two solutions from ircs://irc.libera.chat/guix (dariqq and another one which you could probably get from the GNU Guix channel logs with a quick grep):
If your phase fails on its own, use the --keep-failed
and inspect the directory.
If a phase fails, you do not even have to do anything, except for adding the --keep-failed
flag to guix build
.
After running the guix build
command, somewhere at the end of the guix build
command output, there will be a line similar to the following (I am currently working on package libgit2
version 1.9.0
), telling you where is the source directory where the package is built:
note: keeping build directory `/tmp/guix-build-libgit2-1.9.0.drv-0'
If no phase fails, add a failing phase after a phase you want to inspect.
Add a new phase called 'debug
after the one you want to inspect.
Say you want to inspect the result of the 'build
phase:
(add-after 'build 'debug
(lambda _
(throw 'debug-error "dropping out")))
Then run the guix build
command as you do normally with the --keep-failed
flag which stops the GNU Guix build daemon from deleting the source directory.
Now inspect the source directory as above.
2 Likes
I used to put an unbound symbol inside a phase with the -K argument when I want to interrupt the building process and look into the source code but this is more elegant for sure.
(add-after 'build 'debug
(lambda _
(throw 'debug-error "dropping out")))
I will make a new “tempel” template with this code. Thanks for the hint @cow_2001.
1 Like