fix(coding-agent): use tar instead of unzip for .zip extraction on Windows

Windows does not ship with unzip, causing fd/rg download to fail on
first run in PowerShell. Use tar (bsdtar, available on Windows 10+)
for both .tar.gz and .zip extraction. Also adds proper error checking
on the extraction result.

fixes #1348
This commit is contained in:
Mario Zechner 2026-02-08 15:44:42 +01:00
parent e1b56c1d28
commit 82caf064e0
2 changed files with 16 additions and 4 deletions

View file

@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed fd/rg download failing on Windows due to `unzip` not being available; now uses `tar` for both `.tar.gz` and `.zip` extraction, with proper error reporting ([#1348](https://github.com/badlogic/pi-mono/issues/1348))
## [0.52.8] - 2026-02-07
### New Features

View file

@ -153,10 +153,18 @@ async function downloadTool(tool: "fd" | "rg"): Promise<string> {
mkdirSync(extractDir, { recursive: true });
try {
if (assetName.endsWith(".tar.gz")) {
spawnSync("tar", ["xzf", archivePath, "-C", extractDir], { stdio: "pipe" });
} else if (assetName.endsWith(".zip")) {
spawnSync("unzip", ["-o", archivePath, "-d", extractDir], { stdio: "pipe" });
// Use tar for both .tar.gz and .zip extraction. Windows 10+ ships bsdtar
// which handles both formats, avoiding the need for `unzip` (not available
// on Windows by default).
const extractResult = assetName.endsWith(".tar.gz")
? spawnSync("tar", ["xzf", archivePath, "-C", extractDir], { stdio: "pipe" })
: assetName.endsWith(".zip")
? spawnSync("tar", ["xf", archivePath, "-C", extractDir], { stdio: "pipe" })
: null;
if (!extractResult || extractResult.error || extractResult.status !== 0) {
const errMsg = extractResult?.error?.message ?? extractResult?.stderr?.toString().trim() ?? "unknown error";
throw new Error(`Failed to extract ${assetName}: ${errMsg}`);
}
// Find the binary in extracted files