Bad error message when untracked files are present #570

Open
opened 2024-11-05 17:36:38 +00:00 by rbt · 1 comment
Owner

Describe the bug

When untracked files are present in the current repository, flake commands like nix build, nix develop, and nix run won't copy the files into the Nix store before evaluating, leading to unclear error messages. For example, here's the error message when a file tfc-workspace-deps-twice isn't staged:

error:
       … in the left operand of the update (//) operator

         at /nix/store/hq9dslk3yh73spa7wpgca1ccndnb6qyy-source/flake.nix:120:65:

          119|           in
          120|           (lib.filterAttrs (_name: lib.isDerivation) localPkgs) // {
             |                                                                 ^
          121|             checks = pkgs.releaseTools.aggregate {

       … while calling the 'listToAttrs' builtin

         at /nix/store/c0kv84h9nmr5k18wqrkr4cf4a1cj3z1q-source/lib/attrsets.nix:647:5:

          646|     set:
          647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |     ^
          648|

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "tfc-workspace-deps-twice" at /nix/store/hq9dslk3yh73spa7wpgca1ccndnb6qyy-source/packages/shell/package.nix:15'

Note that Function called without required argument "tfc-workspace-deps-twice" makes no mention of a file tfc-workspace-deps-twice.nix. This is one of those error messages that new users just have to learn means something completely different than what it says.

Expected behavior

There should be a clear and difficult-to-ignore message saying that a file tfc-workspace-deps-twice.nix is untracked and therefore not being copied into the Nix store.

nix --version output

Additional context

Upstream:

Note that git add --intent-to-add / git add -N will stage the file enough for Lix to pick it up.

It might be nice to save warnings and replay them at the end of evaluation; warnings typically occur at the start of a large block of output and therefore are easily ignored.

## Describe the bug When untracked files are present in the current repository, flake commands like `nix build`, `nix develop`, and `nix run` won't copy the files into the Nix store before evaluating, leading to unclear error messages. For example, here's the error message when a file `tfc-workspace-deps-twice` isn't staged: ``` error: … in the left operand of the update (//) operator at /nix/store/hq9dslk3yh73spa7wpgca1ccndnb6qyy-source/flake.nix:120:65: 119| in 120| (lib.filterAttrs (_name: lib.isDerivation) localPkgs) // { | ^ 121| checks = pkgs.releaseTools.aggregate { … while calling the 'listToAttrs' builtin at /nix/store/c0kv84h9nmr5k18wqrkr4cf4a1cj3z1q-source/lib/attrsets.nix:647:5: 646| set: 647| listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set)); | ^ 648| (stack trace truncated; use '--show-trace' to show the full trace) error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "tfc-workspace-deps-twice" at /nix/store/hq9dslk3yh73spa7wpgca1ccndnb6qyy-source/packages/shell/package.nix:15' ``` Note that `Function called without required argument "tfc-workspace-deps-twice"` makes no mention of a _file_ `tfc-workspace-deps-twice.nix`. This is one of those error messages that new users just have to learn means something completely different than what it says. ## Expected behavior There should be a clear and difficult-to-ignore message saying that a file `tfc-workspace-deps-twice.nix` is untracked and therefore not being copied into the Nix store. ## `nix --version` output ## Additional context Upstream: - https://github.com/NixOS/nix/issues/7107 - https://github.com/NixOS/nix/pull/6858 Note that `git add --intent-to-add` / `git add -N` will stage the file enough for Lix to pick it up. It might be nice to save warnings and replay them at the end of evaluation; warnings typically occur at the start of a large block of output and therefore are easily ignored.
rbt added the
ux
Area/flakes
labels 2024-11-05 17:36:38 +00:00
jade added this to the Error reporting project 2024-11-10 02:16:16 +00:00
Owner

related #175

related https://git.lix.systems/lix-project/lix/issues/175
Sign in to join this conversation.
No milestone
No assignees
2 participants
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#570
No description provided.