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

runCommand fails when using __structuredAttrs #213641

Closed
lunik1 opened this issue Jan 30, 2023 · 3 comments
Closed

runCommand fails when using __structuredAttrs #213641

lunik1 opened this issue Jan 30, 2023 · 3 comments
Labels
0.kind: bug Something is broken

Comments

@lunik1
Copy link
Contributor

lunik1 commented Jan 30, 2023

Describe the bug

The trivial runCommand builder (and friends) fails on a trivial derivation when __structuredAttrs is set.

Steps To Reproduce

Steps to reproduce the behaviour:

  1. Build the following derivation:
runCommand "foo" {__structuredAttrs = true;} ''. .attrs.sh; mkdir ''${outputs[out]}''

and get this error

error: builder for '/nix/store/vj7a0vhacspbvfjyngqf12iq8gj9vagz-foo.drv' failed with exit code 1;
       last 1 log lines:
       > /nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh: line 1: /setup: No such file or directory
       For full logs, run 'nix log /nix/store/vj7a0vhacspbvfjyngqf12iq8gj9vagz-foo.drv'.

Expected behavior

Derivation should build, akin to

runCommand "foo" {} ''mkdir $out''

Additional context

There is a partial workaround seen here where builder is set instead of buildCommand, however this leaves the utility functions defined in setup.sh unavailable to the builder.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here
@lunik1 lunik1 added the 0.kind: bug Something is broken label Jan 30, 2023
@abathur
Copy link
Member

abathur commented Feb 20, 2023

Idk why it would be the case, but the error itself sounds like the $stdenv var is empty when trying to run default-builder.sh:

if [ -f .attrs.sh ]; then
. .attrs.sh
fi
source $stdenv/setup
genericBuild

Not sure if this might be related to 238a605 or if that's a red herring.

@abathur
Copy link
Member

abathur commented Feb 20, 2023

I ended up here because someone reported a slightly different message on matrix (/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh: line 6: genericBuild: command not found while rebuilding on NixOS) that sounds like it might also be caused by $stdenv being unset if errexit was enabled in the running script in your case but not in theirs.

That said, someone suggested that they try verifying the store, and they eventually reported that repairing the store solved the problem for then.

I suspect this means their case isn't actually related to the issue here, but I decided to document it just in case it helps connect dots later.

@Artturin
Copy link
Member

Artturin commented Feb 20, 2023

Works for me

that error you're getting is from before structuredAttrs support was added, structuredAttrs currently only works on master/unstable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants