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
breakpointHook: add for debugging failing builds #42371
Conversation
Before merging this I would like to write nixpkgs documentation. |
No attempt on x86_64-darwin (full log) The following builds were skipped because they don't evaluate on x86_64-darwin: breakpointHook, cntr Partial log (click to expand)
|
Failure on aarch64-linux (full log) Attempted: breakpointHook, cntr Partial log (click to expand)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document -t
and --type command
in cntr attach --help
and in cntr readme?
local no_color='\033[0m' | ||
|
||
echo -e "${red}build failed in ${curPhase} with exit code ${exitCode}${no_color}" | ||
printf "To attach install cntr into your profile and run the following command as root:\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"into your profile" is not necessary.
Success on x86_64-linux (full log) Attempted: breakpointHook, cntr Partial log (click to expand)
|
printf "To attach install cntr into your profile and run the following command as root:\n\n" | ||
sh -c "echo ' cntr attach -t command cntr-${out}'; while true; do sleep 99999999; done" | ||
} | ||
failureHooks+=(breakpointHook) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should also add an exitHook that fails the build to avoid accidental inclusion in a pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not do that because:
propagatedBuildInputs = [ breakpointHook ];
can be quite useful as well.
If this really becomes a problem we can still grep with ofBorg in the git diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, nevermind then
No attempt on x86_64-darwin (full log) The following builds were skipped because they don't evaluate on x86_64-darwin: breakpointHook, cntr Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: breakpointHook, cntr Partial log (click to expand)
|
Failure on aarch64-linux (full log) Attempted: breakpointHook, cntr Partial log (click to expand)
|
8ec50dc
to
d075499
Compare
@GrahamcOfBorg build cntr |
No attempt on x86_64-darwin (full log) The following builds were skipped because they don't evaluate on x86_64-darwin: cntr Partial log (click to expand)
|
Failure on aarch64-linux (full log) Attempted: cntr Partial log (click to expand)
|
No attempt on x86_64-darwin (full log) The following builds were skipped because they don't evaluate on x86_64-darwin: breakpointHook, cntr Partial log (click to expand)
|
Failure on aarch64-linux (full log) Attempted: breakpointHook, cntr Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: breakpointHook, cntr Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: cntr Partial log (click to expand)
|
Usuage: Add breakpointHook to your `buildInputs` like this: stdenv.mkDerivation rec { # ... buildInputs = [ breakpointHook ]; }); When the build fails as show in this example: pkgs.hello.overrideAttrs (old: { buildInputs = [ breakpointHook ]; postPatch = '' false ''; }); It will halt execution printing the following message: build failed in patchPhase with exit code 1 To attach to this build run the following command as root: cntr attach -t command cntr-/nix/store/ynyb4n82x2r7sldd58pbb405jdqh5f00-hello-2.10 Installing cntr and running the command will provide shell access to the build sandbox of failed build: sudo cntr attach -t command cntr-/nix/store/ynyb4n82x2r7sldd58pbb405jdqh5f00-hello-2.10 WARNING: bad ownership on /nix/var/nix/profiles/per-user/root, should be 1000 [nixbld@localhost:/var/lib/cntr]$ At /var/lib/cntr the sandbox filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the `cntr exec` subcommand.
d075499
to
325a569
Compare
@GrahamcOfBorg build cntr |
No attempt on aarch64-linux (full log) The following builds were skipped because they don't evaluate on aarch64-linux: cntr Partial log (click to expand)
|
No attempt on x86_64-darwin (full log) The following builds were skipped because they don't evaluate on x86_64-darwin: cntr Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: cntr Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: breakpointHook The following builds were skipped because they don't evaluate on aarch64-linux: cntr Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: breakpointHook, cntr Partial log (click to expand)
|
No attempt on x86_64-darwin (full log) The following builds were skipped because they don't evaluate on x86_64-darwin: breakpointHook, cntr Partial log (click to expand)
|
Just in time for the talk! |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/debugging-broken-builds/3138/5 |
Motivation for this change
Usage: Add breakpointHook to your
buildInputs
like this:When the build fails as show in this example:
It will halt execution printing the following message:
Installing cntr and running the command will provide shell access to the
build sandbox of failed build:
At /var/lib/cntr the sandbox filesystem is mounted. All commands and
files of the system are still accessible within the shell.
To execute commands from the sandbox use the
cntr exec
subcommand.Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)