Skip to content

fix: make --rebuild failures actionable#14855

Merged
Mic92 merged 1 commit intoNixOS:masterfrom
NoRePercussions:norepercussions/push-ymokollxlmvw
Dec 26, 2025
Merged

fix: make --rebuild failures actionable#14855
Mic92 merged 1 commit intoNixOS:masterfrom
NoRePercussions:norepercussions/push-ymokollxlmvw

Conversation

@NoRePercussions
Copy link
Contributor

See #8188. Resolves issues about the error not being actionable, but I am not marking it closing yet because of further discussion about the naming of these flags in the thread.

nix build --rebuild (and others) will fail if the derivation has not been built before, because it runs a check build and confirms that the build was deterministic.

It may be unclear to users that --rebuild will fail if the derivation has never been built before, because the flag makes no indication that a determinism check occurs.

The error message does not help clear this up, or provide any actionable steps, and at first glance seems to indicate that the derivation being built is invalid, rather than just not present in the store:

error: some outputs of '...' are not valid, so checking is not possible

We can suggest to the user the following (correct) rewrites. This list of commands that may result in the error is comprehensive.

  • nix build --rebuild to nix build or nix build --repair
  • nix-build --check to nix-build or nix-build --repair
  • nix-store --realise --check to nix-store --realise or nix-store --realise --repair

Wording is based on that in the documentation:

(nix build)
--repair During evaluation, rewrite missing or
         corrupted files in the Nix store. During
         building, rebuild missing or corrupted
         store paths.

(nix-build)
--repair Fix corrupted or missing store paths by
         redownloading or rebuilding them. Note
         that this is slow because it requires
         computing a cryptographic hash of the
         contents of every path in the closure
         of the build. Also note the warning
         under nix-store --repair-path.

(nix-store --realise)
--repair Fix corrupted or missing store paths by
         redownloading or rebuilding them. (etc)

Motivation

Make errors on --rebuild actionable for users who expect it to idempotently perform a build.

Context

Issue: #8188.

Just an updated error message with a hint for clarity. Works for all possible invocations that can throw that error.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

See NixOS#8188. Resolves issues about the error not
being actionable, but I am not marking it closing
yet because of further discussion about the naming
of these flags in the thread.

`nix build --rebuild` (and others)
will fail if the derivation has not been built
before, because it runs a check build and
confirms that the build was deterministic.

It may be unclear to users that --rebuild will fail
if the derivation has never been built before,
because the flag makes no indication that a
determinism check occurs.

The error message does
not help clear this up, or provide any actionable
steps, and at first glance seems to indicate that
the derivation being built is invalid, rather than
just not present in the store:

```
error: some outputs of '...' are not valid, so checking is not possible
```

We can suggest to the user the following (correct)
rewrites. This list of commands that may result in
the error is comprehensive.

- `nix build --rebuild` to `nix build` or `nix build --repair`
- `nix-build --check` to `nix-build` or `nix-build --repair`
- `nix-store --realise --check` to `nix-store --realise` or `nix-store --realise --repair`

Wording is based on that in the documentation:

```
(nix build)
--repair During evaluation, rewrite missing or
         corrupted files in the Nix store. During
         building, rebuild missing or corrupted
         store paths.

(nix-build)
--repair Fix corrupted or missing store paths by
         redownloading or rebuilding them. Note
         that this is slow because it requires
         computing a cryptographic hash of the
         contents of every path in the closure
         of the build. Also note the warning
         under nix-store --repair-path.

(nix-store --realise)
--repair Fix corrupted or missing store paths by
         redownloading or rebuilding them. (etc)
```
@Mic92 Mic92 enabled auto-merge December 26, 2025 11:31
@Mic92 Mic92 added this pull request to the merge queue Dec 26, 2025
Merged via the queue into NixOS:master with commit cfe5fc6 Dec 26, 2025
16 checks passed
@NoRePercussions NoRePercussions deleted the norepercussions/push-ymokollxlmvw branch December 26, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants