[package-deps-hash] Skip Windows reserved device names when computing repo state (fixes #5604)#5805
Open
LeSingh1 wants to merge 1 commit into
Open
Conversation
… repo state
`getRepoState`/`getDetailedRepoStateAsync` feed the set of locally-modified
files through `git hash-object`. When one of those files happens to be a
Windows reserved device name (e.g. `nul`, `con`, `aux`, `com1`-`com9`,
`lpt1`-`lpt9`) -- typically a stray artifact from a misdirected shell
redirect -- `git hash-object` cannot open the path and the entire
`spawnGitAsync` call exits with the unhelpful
fatal: could not open '<path>/nul' for reading: No such file or directory
aborting `rush build` (and any other Rush command that consults repo state).
This patch filters such basenames on Windows before they reach git. The
helper handles paths with or without an extension, with either forward or
backslash separators, and is case-insensitive (matching Win32 semantics).
Tracked files cannot use these names on Windows checkouts, so filtering on
the working-tree side is sufficient.
Fixes microsoft#5604
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.
Summary
getRepoState/getDetailedRepoStateAsyncfeed the set of locally-modified files throughgit hash-object. When one of those files happens to be a Windows reserved device name (nul,con,aux,com1-com9,lpt1-lpt9) — typically a stray artifact from a misdirected shell redirect —git hash-objectcannot open the path and the entirespawnGitAsynccall exits with:aborting
rush build(and any other Rush command that consults repo state). This is increasingly common as AI coding agents leavenulartifacts behind, per the issue body.Fix
Added an internal
isWindowsReservedPath(filePath)helper togetRepoState.tsand use it ingetDetailedRepoStateAsync'sgetFilesToHashgenerator to skip such files whenprocess.platform === 'win32'. The helper:nul,nul.txt,aux.log.bak);/or\\separators;packages/nul-suffix/index.tsis not affected).Tracked files cannot use these names on a Windows checkout (git refuses to materialize them), so filtering on the working-tree side is sufficient.
Tests
Added 4 unit-test cases under
libraries/package-deps-hash/src/test/getRepoState.test.tscovering bare names, names with extensions, nested paths with both separator styles, and negative cases (null,console.ts,com.ts,lpt10,packages/nul-suffix/...).Logic verified locally with a node script (15/15 cases pass). I did not run the full Rushstack heft test suite locally; if CI catches anything I'll iterate.
Changeset
patchfor@rushstack/package-deps-hash.Issue
Fixes #5604