From 96bdc9e9351a25eda4ce6277b91a2334dacbd37f Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Fri, 24 Oct 2025 08:29:40 +0200 Subject: [PATCH] Fall back to extractZip() if extractTar() fails extractTar() supporst both bsdtar and gnu tar, but only bsdtar supports zip files. While on GH hosted runners bsdtar is used by default that might not be true for other setups, so in case extractTar() fails we fall back to extractZip() and print a message. --- dist/setup/index.js | 14 +++++++++++++- src/download/download-version.ts | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index df05871..ab1d6b3 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -129171,6 +129171,7 @@ exports.tryGetFromToolCache = tryGetFromToolCache; exports.downloadVersionFromGithub = downloadVersionFromGithub; exports.downloadVersionFromManifest = downloadVersionFromManifest; exports.resolveVersion = resolveVersion; +const node_fs_1 = __nccwpck_require__(73024); const path = __importStar(__nccwpck_require__(76760)); const core = __importStar(__nccwpck_require__(37484)); const tc = __importStar(__nccwpck_require__(33472)); @@ -129212,7 +129213,18 @@ async function downloadVersion(downloadUrl, artifactName, platform, arch, versio let uvDir; if (platform === "pc-windows-msvc") { // On windows extracting the zip does not create an intermediate directory - uvDir = await tc.extractTar(downloadPath, undefined, "x"); + try { + // Try tar first as it's much faster, but only bsdtar supports zip files, + // so this my fail if another tar, like gnu tar, ends up being used. + uvDir = await tc.extractTar(downloadPath, undefined, "x"); + } + catch (err) { + core.info(`Extracting with tar failed, falling back to zip extraction: ${err.message}`); + const extension = getExtension(platform); + const fullPathWithExtension = `${downloadPath}${extension}`; + await node_fs_1.promises.copyFile(downloadPath, fullPathWithExtension); + uvDir = await tc.extractZip(fullPathWithExtension); + } } else { const extractedDir = await tc.extractTar(downloadPath); diff --git a/src/download/download-version.ts b/src/download/download-version.ts index 5a9f207..5c71e6c 100644 --- a/src/download/download-version.ts +++ b/src/download/download-version.ts @@ -110,7 +110,19 @@ async function downloadVersion( let uvDir: string; if (platform === "pc-windows-msvc") { // On windows extracting the zip does not create an intermediate directory - uvDir = await tc.extractTar(downloadPath, undefined, "x"); + try { + // Try tar first as it's much faster, but only bsdtar supports zip files, + // so this my fail if another tar, like gnu tar, ends up being used. + uvDir = await tc.extractTar(downloadPath, undefined, "x"); + } catch (err) { + core.info( + `Extracting with tar failed, falling back to zip extraction: ${(err as Error).message}`, + ); + const extension = getExtension(platform); + const fullPathWithExtension = `${downloadPath}${extension}`; + await fs.copyFile(downloadPath, fullPathWithExtension); + uvDir = await tc.extractZip(fullPathWithExtension); + } } else { const extractedDir = await tc.extractTar(downloadPath); uvDir = path.join(extractedDir, artifactName);