mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-22 00:00:27 +00:00
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:
parent
e1b56c1d28
commit
82caf064e0
2 changed files with 16 additions and 4 deletions
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [0.52.8] - 2026-02-07
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,18 @@ async function downloadTool(tool: "fd" | "rg"): Promise<string> {
|
||||||
mkdirSync(extractDir, { recursive: true });
|
mkdirSync(extractDir, { recursive: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (assetName.endsWith(".tar.gz")) {
|
// Use tar for both .tar.gz and .zip extraction. Windows 10+ ships bsdtar
|
||||||
spawnSync("tar", ["xzf", archivePath, "-C", extractDir], { stdio: "pipe" });
|
// which handles both formats, avoiding the need for `unzip` (not available
|
||||||
} else if (assetName.endsWith(".zip")) {
|
// on Windows by default).
|
||||||
spawnSync("unzip", ["-o", archivePath, "-d", extractDir], { stdio: "pipe" });
|
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
|
// Find the binary in extracted files
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue