libstore: escape store paths when unparsing derivations - #16343
Open
awsmadi wants to merge 2 commits into
Open
Conversation
awsmadi
marked this pull request as ready for review
August 21, 2026 19:24
Member
|
Let's do this after #16284 |
printUnquotedString() escapes nothing, so store paths written through it went into the .drv verbatim. On Unix that is harmless -- store paths contain no character printString() would escape -- but on Windows they contain backslashes, which the reader's escape table then mis-decodes: `\n` in `...\nix\store` becomes a literal newline, and the path fails to round-trip. A single .drv therefore disagreed with itself, carrying the same store path unescaped in the outputs field and correctly escaped in the env field. Reading it back gave: path 'C:ProgramData<newline>ixstore/...' is not in the Nix store. Use printString() for the four store-path writes. printString() is a superset of printUnquotedString(): for any input containing none of " \ \n \r \t the two produce byte-identical output, so this cannot change a .drv, a derivation hash or a cache entry on Unix. Verified: nix-store-tests is unmoved at 764 passed / 12 failed with the same twelve test names. Not claimed: that this makes building work on Windows. Realising a derivation stops earlier, at an explicit UnimplementedError, because no Windows derivation builder exists. Assisted-by: Claude Code (claude-opus-5)
awsmadi
force-pushed
the
pr/aterm-escape-store-paths
branch
from
August 24, 2026 15:28
a2cefb0 to
bbf2132
Compare
Assisted-by: Claude Code (claude-opus-5)
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.
printUnquotedStringescapes nothing, so store paths written through it land in the.drvverbatim. Harmless on Unix, where store paths contain no characterprintStringwould escape. On Windows they contain backslashes, and the reader'sescape table then mis-decodes them:
\nin...\nix\storebecomes a literalnewline and the path fails to round-trip.
The artefact indicts itself. One
.drvcarried the same store path twice, unescapedin the outputs field and escaped in the env field:
Reading it back gave
path 'C:ProgramData<newline>ixstore/...' is not in the Nix store.This switches the four store-path writes in
unparsetoprintString.Nothing can change on Unix.
printStringis a superset ofprintUnquotedString:for input containing none of
",\,\n,\r,\tthe two produce identicalbytes, and store paths on Unix contain none of them. So no
.drv, derivation hashor cache entry moves. Checked rather than assumed:
nix-store-testsis unmoved at764 passed / 12 failed across both arms with the same twelve names, and a
deliberately different store hash does move the output, so the comparison could
have detected a change.
This does not make building work on Windows. Realising a derivation stops earlier
for want of a builder.