Unhelpfull error message on corrupted derivation "expected string 'D'" #447

Open
opened 2024-07-13 11:36:37 +00:00 by pr2502 · 0 comments

Describe the bug

When the nix store is corrupted in such a way that a derivation file (.drv) is empty the parsing fails with broken looking and not very helpful error message:

fetching path input 'path:/nix/store/dk2rpyb6ndvfbf19bkb2plcz5y3k8i5v-source'
error:
       … while evaluating 'strict' to select 'drvPath' on it
         at /builtin/derivation.nix:1:552:
       … while calling the 'derivationStrict' builtin
         at /builtin/derivation.nix:1:208:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: error parsing derivation '/nix/store/qw0v3wzkvbipjbvbba36f7i3zjqg7n3f-source.drv': error: expected string 'D'

Steps To Reproduce

  1. create any derivation like
    nix-repl> derivation { name = "expected-d-repro"; system = builtins.currentSystem; builder = "builder"; }
    «derivation /nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv»
    
  2. corrupt the derivation
    $ sudo mount -o remount,rw /nix/store
    $ sudo truncate -s0 /nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv
    
  3. attempt to build the corrupted derivation
    $ nix-build /nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv
    error: error parsing derivation '/nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv': error: expected string 'D'
    

Expected behavior

I'd expect a bit more descriptive error message, probably a suggestion to run nix-store --verify-path <drvpath> and maybe even how to fix it? in this case that's nix-store --delete <drvpath> but I'm not sure if that's universally applicable. nix-store --repair-path <drvpath> definitely did not work in this case.

nix --version output

nix (Lix, like Nix) 2.91.0-dev-pre20240705-b6a08a2

## Describe the bug When the nix store is corrupted in such a way that a derivation file (.drv) is empty the parsing fails with broken looking and not very helpful error message: ``` fetching path input 'path:/nix/store/dk2rpyb6ndvfbf19bkb2plcz5y3k8i5v-source' error: … while evaluating 'strict' to select 'drvPath' on it at /builtin/derivation.nix:1:552: … while calling the 'derivationStrict' builtin at /builtin/derivation.nix:1:208: (stack trace truncated; use '--show-trace' to show the full trace) error: error parsing derivation '/nix/store/qw0v3wzkvbipjbvbba36f7i3zjqg7n3f-source.drv': error: expected string 'D' ``` ## Steps To Reproduce 1. create any derivation like ``` nix-repl> derivation { name = "expected-d-repro"; system = builtins.currentSystem; builder = "builder"; } «derivation /nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv» ``` 2. corrupt the derivation ``` $ sudo mount -o remount,rw /nix/store $ sudo truncate -s0 /nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv ``` 3. attempt to build the corrupted derivation ``` $ nix-build /nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv error: error parsing derivation '/nix/store/s1fiwaika47si98h0297sldnqqalyrx2-expected-d-repro.drv': error: expected string 'D' ``` ## Expected behavior I'd expect a bit more descriptive error message, probably a suggestion to run `nix-store --verify-path <drvpath>` and maybe even how to fix it? in this case that's `nix-store --delete <drvpath>` but I'm not sure if that's universally applicable. `nix-store --repair-path <drvpath>` definitely did not work in this case. ## `nix --version` output `nix (Lix, like Nix) 2.91.0-dev-pre20240705-b6a08a2`
pr2502 added the
bug
label 2024-07-13 11:36:37 +00:00
qyriad added the
ux
Area/store
labels 2024-07-13 17:06:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#447
No description provided.