Skip to content

[package-deps-hash] Skip Windows reserved device names when computing repo state (fixes #5604)#5805

Open
LeSingh1 wants to merge 1 commit into
microsoft:mainfrom
LeSingh1:fix/skip-windows-reserved-filenames
Open

[package-deps-hash] Skip Windows reserved device names when computing repo state (fixes #5604)#5805
LeSingh1 wants to merge 1 commit into
microsoft:mainfrom
LeSingh1:fix/skip-windows-reserved-filenames

Conversation

@LeSingh1
Copy link
Copy Markdown

Summary

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 (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:

fatal: could not open 'apps/admin-powerplatform-microsoft-com/nul' for reading: No such file or directory

aborting rush build (and any other Rush command that consults repo state). This is increasingly common as AI coding agents leave nul artifacts behind, per the issue body.

Fix

Added an internal isWindowsReservedPath(filePath) helper to getRepoState.ts and use it in getDetailedRepoStateAsync's getFilesToHash generator to skip such files when process.platform === 'win32'. The helper:

  • handles paths with or without an extension (nul, nul.txt, aux.log.bak);
  • accepts either / or \\ separators;
  • is case-insensitive (matches Win32 semantics);
  • only matches the final path segment (so packages/nul-suffix/index.ts is 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.ts covering 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

patch for @rushstack/package-deps-hash.

Issue

Fixes #5604

… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

[rush] rush build with a file called "nul" in repo causes "Error calculating state of the repo"

1 participant