Repository navigation
typespec-java, Read pinned core sources via git archive zip instead of tar - #4983
Merged
Weidong Xu (weidongxu-microsoft) merged 1 commit intoJul 21, 2026
Merged
Conversation
CoreCommit.ps1 extracted the pinned core/ commit with an external ar, which fails on Windows because Git for Windows' GNU tar treats an archive path containing a drive letter (C:\...\core.tar) as a remote host spec and aborts with "Cannot connect to C:". Use git archive --format=zip plus the built-in Expand-Archive instead, keeping the whole flow inside PowerShell/.NET with no external archiver dependency. core/ is still never checked out. Also refresh CONTRIBUTING.md, which still described the old in-place core/ checkout and git checkout . patch flow, to match the current archive-based read and copy-and-patch generator flow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec1f621b-9580-4bac-9ef4-41b057cca012
Weidong Xu (weidongxu-microsoft)
force-pushed
the
fix-java-core-archive-tar-windows
branch
from
July 21, 2026 05:20
663b83d to
1221701
Compare
Contributor
|
All changed packages have been documented.
Show changes
|
commit: |
Contributor
|
You can try these changes here
|
Xiaofei Cao (XiaofeiCao)
approved these changes
Jul 21, 2026
Xiaofei Cao (XiaofeiCao)
approved these changes
Jul 21, 2026
Weidong Xu (weidongxu-microsoft)
marked this pull request as ready for review
July 21, 2026 06:16
Weidong Xu (weidongxu-microsoft)
deleted the
fix-java-core-archive-tar-windows
branch
July 21, 2026 07:46
Yuchao Yan (msyyc)
pushed a commit
to msyyc/typespec-azure
that referenced
this pull request
Jul 22, 2026
…5004) ## Problem A full-repo `pnpm build` intermittently **hangs at the Java emitter build**. The output stops right after: ``` @azure-tools/typespec-java:build: core-commit.json SHA ... using current checkout. ``` and never reaches `Copy generator sources from core`. Building `packages/typespec-java` on its own always works. Prior attempts (Azure#4972, Azure#4983, and non-interactive/fetch hardening) did not resolve it. ## Root cause turbo runs each task's process in its own **background process group** under the build's **controlling terminal** (the TUI). When a PowerShell cmdlet renders **`Write-Progress`** — which `Copy-Item -Recurse` in `Copy-Sources.ps1` does — pwsh touches that terminal from a background process group and the OS stops the process with **SIGTTIN/SIGTTOU** (`T` state). It never resumes, so the build hangs forever. This explains all the symptoms: - **Java-only:** it is the only package that shells out to `pwsh`. - **Intermittent:** `Copy-Item` only renders progress when the copy is slow enough (under parallel-build load). - **Invisible when piped / in isolation:** with piped output (no TUI) or a standalone build, pwsh is not a background process group of a controlling terminal, so nothing stops it. - **Unaffected by `-NonInteractive`:** progress renders regardless. Reproduced directly: a pwsh running `Write-Progress` in a background process group under a controlling tty immediately enters `T` (stopped); with `$ProgressPreference = 'SilentlyContinue'` it never stops. ## Fix - Set `$ProgressPreference = 'SilentlyContinue'` in `Copy-Sources.ps1`, `Build-Generator.ps1`, and `CoreCommit.ps1` so no cmdlet touches the controlling terminal. **This is the actual fix.** Complementary hardening (removes secondary hang/network vectors): - `CoreCommit.ps1`: only `git fetch` the pinned core commit when it is genuinely missing locally (`git cat-file -e <sha>^{commit}` first) — previously it hit the network on *every* emitter build / doc regen. - `CoreCommit.ps1`: `GIT_TERMINAL_PROMPT=0` and `pwsh -NonInteractive` (package.json) so a git credential/host prompt can never block the headless build. - `CoreCommit.ps1`: extract pinned sources with `[System.IO.Compression.ZipFile]::ExtractToDirectory` instead of the pathologically slow `Expand-Archive`. ## Verification - Reproduced the `T`-state stop with `Write-Progress` under a controlling tty; confirmed `$ProgressPreference='SilentlyContinue'` prevents it. - 8/8 runs of the real `Copy-Sources.ps1` in a background process group under a controlling tty never stop. - Full `pnpm build` completes 63/63; `git -C core status` stays clean.
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.
Problem
Following #4972,
packages/typespec-java/CoreCommit.ps1reads the pinnedcore/commit's sources bygit archiveinto a temp dir and then extracts them with an externaltar. On Windows this fails: thetarfirst on PATH is Git for Windows' GNUtar, which interprets the archive path-f C:\...\core.taras a remote host (host:pathrsh syntax) and aborts:Linux CI doesn't hit this (
/tmp/...has no drive-letter colon), so it only bites Windows dev builds.Fix
Get-CoreSourceRootnow archives withgit archive --format=zipand extracts with PowerShell's built-inExpand-Archive(System.IO.Compression). This keeps the whole flow inside PowerShell/.NET with no external archiver dependency and no drive-letter parsing quirk.core/is still never checked out or modified, and the temp dir is still cleaned up byRemove-CoreSourceRoot.Also refreshes
CONTRIBUTING.md, which still described the pre-#4972 in-placecore/checkout /git checkout .patch flow, to match the currentgit archiveread and copy-and-patch-the-generator flow.Verification
Pinned
core-commit.jsonto a commit newer than the currentcorecheckout to force the archive path, then ranCopy-Sources.ps1:git archive --format=zip+Expand-Archivesucceeded; generator copied andcore.patchapplied;exit=0.git -C core statusclean (submodule untouched), pin restored, no temp dir leaked.