mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 12:03:23 +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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue