tools: check_conventions.py fails on Windows with WinError 206, its duplicate-export git grep is longer than the 32k command line #8848

Closed
opened 2026-10-21 02:59:10 +00:00 by 011010 · 5 comments
011010 commented 2026-10-21 02:59:10 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-21T02:59:10Z.


python tools/check_conventions.py --base origin/main cannot complete on Windows. It stops in duplicates(), before any check has run, with:

File "C:\...\AnyPS5\tools\check_conventions.py", line 210, in duplicates
  result = subprocess.run(["git", "-c", "core.quotePath=false", "grep", "-nE", "--full-name", pattern, self.head, "--", ":(top)core/libs/prx"], capture_output=True, encoding="utf-8", errors="replace")
File "C:\Python314\Lib\subprocess.py", line 1552, in _execute_child
  hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ...)
FileNotFoundError: [WinError 206] The filename or extension is too long

Environment: Windows 11, Python 3.14.3, git 2.52.0.windows.1, tree at main 5d10ea9ea.

Cause. duplicates() passes one regular expression, built from every export in the tree, as a single argv element. On this tree that is 4,445 names and a 147,788-character expression. Windows builds the process from one command line capped at 32,767 characters, so CreateProcess refuses it before Git starts. core.longpaths does not help: the limit is the command line, not a path. Linux has an ARG_MAX of about 2 MB, so the CI job never reaches it.

With duplicates() made to return immediately, the rest of the check runs on Windows and reports the other findings normally, so this step is the only one that fails there.

Verified alternative. git grep reads expressions from a file with -f. Writing the same expression to a file and passing -f <file> returns the expected hits on the same tree here (7,835 lines for the version of the expression measured above) without any command-line growth:

with tempfile.TemporaryDirectory() as directory:
    patterns = Path(directory) / "exports"
    patterns.write_text(pattern + "\n", encoding="utf-8")
    result = subprocess.run(["git", "-c", "core.quotePath=false", "grep", "-nE", "--full-name", "-f", str(patterns), self.head, "--", ":(top)core/libs/prx"], capture_output=True, encoding="utf-8", errors="replace")

The file must be written without a BOM or the first alternative does not match (writing with the default Set-Content -Encoding utf8 of Windows PowerShell added one in my check and made the run return 0 hits).

Why it matters. AGENTS.md and CONTRIBUTING.md tell contributors to run this check before pushing. On Windows the command fails regardless of the change, so a Windows contributor has no local run of it and only the CI job sees the result. CI is unaffected.

Coordination. #8777 edits this same function to count assembly exports, so the two changes should be reconciled in whichever lands second.

I can open the pull request with the -f change and a test that the expression is not passed on the command line, if that is wanted.

AI-assisted: yes (Claude Code). The traceback and the measurements above come from my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5953483081 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8848). Originally posted by [011010](https://github.com/011010) on 2026-10-21T02:59:10Z. --- `python tools/check_conventions.py --base origin/main` cannot complete on Windows. It stops in `duplicates()`, before any check has run, with: ``` File "C:\...\AnyPS5\tools\check_conventions.py", line 210, in duplicates result = subprocess.run(["git", "-c", "core.quotePath=false", "grep", "-nE", "--full-name", pattern, self.head, "--", ":(top)core/libs/prx"], capture_output=True, encoding="utf-8", errors="replace") File "C:\Python314\Lib\subprocess.py", line 1552, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ...) FileNotFoundError: [WinError 206] The filename or extension is too long ``` Environment: Windows 11, Python 3.14.3, git 2.52.0.windows.1, tree at `main` `5d10ea9ea`. **Cause.** `duplicates()` passes one regular expression, built from every export in the tree, as a single argv element. On this tree that is 4,445 names and a 147,788-character expression. Windows builds the process from one command line capped at 32,767 characters, so `CreateProcess` refuses it before Git starts. `core.longpaths` does not help: the limit is the command line, not a path. Linux has an `ARG_MAX` of about 2 MB, so the CI job never reaches it. With `duplicates()` made to return immediately, the rest of the check runs on Windows and reports the other findings normally, so this step is the only one that fails there. **Verified alternative.** `git grep` reads expressions from a file with `-f`. Writing the same expression to a file and passing `-f <file>` returns the expected hits on the same tree here (7,835 lines for the version of the expression measured above) without any command-line growth: ```python with tempfile.TemporaryDirectory() as directory: patterns = Path(directory) / "exports" patterns.write_text(pattern + "\n", encoding="utf-8") result = subprocess.run(["git", "-c", "core.quotePath=false", "grep", "-nE", "--full-name", "-f", str(patterns), self.head, "--", ":(top)core/libs/prx"], capture_output=True, encoding="utf-8", errors="replace") ``` The file must be written without a BOM or the first alternative does not match (writing with the default `Set-Content -Encoding utf8` of Windows PowerShell added one in my check and made the run return 0 hits). **Why it matters.** `AGENTS.md` and `CONTRIBUTING.md` tell contributors to run this check before pushing. On Windows the command fails regardless of the change, so a Windows contributor has no local run of it and only the CI job sees the result. CI is unaffected. **Coordination.** #8777 edits this same function to count assembly exports, so the two changes should be reconciled in whichever lands second. I can open the pull request with the `-f` change and a test that the expression is not passed on the command line, if that is wanted. AI-assisted: yes (Claude Code). The traceback and the measurements above come from my machine.
MarcZX10 commented 2026-10-21 03:19:49 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:19:49Z.


I found open PR #8777, which already changes duplicates() to detect assembly exports and addresses the same function. The regex it builds is still 147,788 characters at the measured 4,445-export size, so it would still hit the Windows CreateProcess limit. I suggested in that PR that the author include your measured git grep -f approach and a regression test, avoiding a competing PR on the same method.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307189542 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8848#issuecomment-6307189542). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T03:19:49Z. --- I found open PR #8777, which already changes `duplicates()` to detect assembly exports and addresses the same function. The regex it builds is still 147,788 characters at the measured 4,445-export size, so it would still hit the Windows `CreateProcess` limit. I suggested in that PR that the author include your measured `git grep -f` approach and a regression test, avoiding a competing PR on the same method.
MarcZX10 commented 2026-10-21 03:30:05 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:30:05Z.


Fixed on current main by #8461. The merged checker passes fixed-string patterns to git grep -f - through stdin instead of constructing a long argv regex. The PR reports a Windows regression that reproduced WinError 206 on main and passed with the change, and the merged Windows relinker job passed. I also flagged that open #8777 needs to preserve this approach when it adds assembly-export detection, or it could reintroduce the same limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307313434 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8848#issuecomment-6307313434). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T03:30:05Z. --- Fixed on current main by #8461. The merged checker passes fixed-string patterns to `git grep -f -` through stdin instead of constructing a long argv regex. The PR reports a Windows regression that reproduced WinError 206 on main and passed with the change, and the merged Windows relinker job passed. I also flagged that open #8777 needs to preserve this approach when it adds assembly-export detection, or it could reintroduce the same limit.
MarcZX10 commented 2026-10-21 03:30:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:30:11Z.


The reported Windows command-line failure is fixed on current main by #8461. The merged checker passes fixed-string patterns to git grep -f - through stdin, and #8461 reports a Windows regression that reproduced WinError 206 on main and passed with the fix. Its Windows relinker job also passed. I flagged open #8777 because it still uses the older long regex as one argv item; its assembly-export change should be rebased and keep the streamed-pattern approach to avoid reintroducing this failure. I cannot close the issue with the permissions on this account, but the specific failure is covered by the merged change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307314903 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8848#issuecomment-6307314903). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T03:30:11Z. --- The reported Windows command-line failure is fixed on current `main` by #8461. The merged checker passes fixed-string patterns to `git grep -f -` through stdin, and #8461 reports a Windows regression that reproduced WinError 206 on main and passed with the fix. Its Windows relinker job also passed. I flagged open #8777 because it still uses the older long regex as one argv item; its assembly-export change should be rebased and keep the streamed-pattern approach to avoid reintroducing this failure. I cannot close the issue with the permissions on this account, but the specific failure is covered by the merged change.
MarcZX10 commented 2026-10-21 04:18:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T04:18:41Z.


I checked current main: #8461 (fix(tools): stream duplicate export search patterns) already moved git grep patterns off the command line using -F -f -, which addresses the reported WinError 206. I also reviewed #8777, which extends this duplicate check to assembly exports; its current diff builds a combined regex and passes that full pattern as an argv element again. I left an inline note there asking to keep that expanded pattern off argv while preserving the needed matching behavior. The issue can be closed once the author confirms the current-main fix covers the reported Windows setup.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307931387 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8848#issuecomment-6307931387). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T04:18:41Z. --- I checked current `main`: #8461 (`fix(tools): stream duplicate export search patterns`) already moved `git grep` patterns off the command line using `-F -f -`, which addresses the reported WinError 206. I also reviewed #8777, which extends this duplicate check to assembly exports; its current diff builds a combined regex and passes that full pattern as an argv element again. I left an inline note there asking to keep that expanded pattern off argv while preserving the needed matching behavior. The issue can be closed once the author confirms the current-main fix covers the reported Windows setup.
011010 commented 2026-10-21 04:26:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-21T04:26:48Z.


Thanks @MarcZX10. Verified on this machine after updating to main 7ab4b2e56: python tools/check_conventions.py --base origin/main now completes on Windows with no WinError 206 (the findings it prints come from comparing against the old fork history, not from the checker). The git grep -nF -f - form from #8461 is the one I measured working.

Closing as fixed. #8777 is still open, now conflicts with main, and still builds the long -E pattern; it needs a rebase that keeps the streamed patterns or it reintroduces this.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308032957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8848#issuecomment-6308032957). Originally posted by [011010](https://github.com/011010) on 2026-10-21T04:26:48Z. --- Thanks @MarcZX10. Verified on this machine after updating to `main` `7ab4b2e56`: `python tools/check_conventions.py --base origin/main` now completes on Windows with no `WinError 206` (the findings it prints come from comparing against the old fork history, not from the checker). The `git grep -nF -f -` form from #8461 is the one I measured working. Closing as fixed. #8777 is still open, now conflicts with `main`, and still builds the long `-E` pattern; it needs a rebase that keeps the streamed patterns or it reintroduces this.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#8848
No description provided.