fix: make --rebuild failures actionable#14855
Merged
Mic92 merged 1 commit intoNixOS:masterfrom Dec 26, 2025
Merged
Conversation
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) ```
tomberek
approved these changes
Dec 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
We can suggest to the user the following (correct) rewrites. This list of commands that may result in the error is comprehensive.
nix build --rebuildtonix buildornix build --repairnix-build --checktonix-buildornix-build --repairnix-store --realise --checktonix-store --realiseornix-store --realise --repairWording is based on that in the documentation:
Motivation
Make errors on
--rebuildactionable 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.