Windows: vendoring fails from Git Bash (GNU tar) — zig-asar and Rust, `Failed with exit code 2`
Building from Git Bash on Windows fails during vendoring. The same commit builds cleanly from PowerShell.
Symptom
Failed to download zig-asar binaries for x64: Failed with exit code 2
Error: Failed to download zig-asar binaries.
at vendorAsar (package/build.ts:1160:22)Work around asar, and vendorRust fails the same way:
Failed to vendor Rust: ShellError: Failed with exit code 2
error: Could not vendor Rust toolchain.The artifacts are fine — zig-asar-win32-x64.tar.gz returns HTTP 200 with a matching sha256, and extracts by hand.
Cause
tar resolution differs by shell:
| shell | tar resolves to |
|---|---|
| Git Bash | /usr/bin/tar — GNU tar 1.34 |
| PowerShell | C:\Windows\System32\tar.exe — bsdtar |
vendorAsar (build.ts:1671) passes a join()-produced backslash absolute path to -C. GNU tar mangles it; bsdtar accepts it:
$ tar -xzf "v2\asar-temp.tar.gz" -C "C:\...\v2\zig-asar\x64"
tar: C\:\Users\...\zig-asar\x64: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now # exit 2
$ /c/Windows/System32/tar.exe -xzf "v2\asar-temp.tar.gz" -C "C:\...\v2\zig-asar\x64"
# exit 0vendorRust (build.ts:1220) has the same symptom and the same fix, but I did not isolate its exact trigger — its -C path is backslash relative, and vendorDawn (build.ts:1591) uses that same shape successfully.
Note: GNU tar's drive-letter-as-remote-host parsing (Cannot connect to C:) applies to -f, not -C, so it is not the cause here — -f gets a relative path.
Why CI misses it
GitHub runners default to pwsh, so CI always gets bsdtar.
Suggested fix
build.ts is inconsistent about this. The call sites that hardcode POSIX-style relative paths work on both tars:
- works —
vendorZstd(1521):tar -xzf ${tempTarball} -C vendors/zig-zstd - works —
vendorBsdiff(1472):-C vendors/zig-bsdiff - fails —
vendorAsar(1671):-C "${asarDir}"whereasarDir = join(process.cwd(), ...)
Making the failing sites use relative POSIX paths like the working ones would fix both. Documenting a required shell in BUILD.md would also help — it currently specifies none, and Failed with exit code 2 gives no clue which command failed or why.
Environment
Windows 11 Pro 26200 · Git Bash (GNU tar 1.34) vs PowerShell (bsdtar) · MSVC 19.44 / VS Build Tools 2022 17.14.37614.0 · Hutch 0.26.0-canary.9
Source: blackboardsh/electrobun