Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prefer gtar if available
  • Loading branch information
cklin committed Feb 14, 2025
commit 61c77a48ff1de3e02ae852e50a5f961232ed5ced
17 changes: 16 additions & 1 deletion src/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ async function getTarVersion(programName: string): Promise<TarVersion> {
}
}

async function pickTarCommand(): Promise<TarVersion> {
// bsdtar 3.5.3 on the macos-14 (arm) action runner image is prone to crash with the following
// error messages when extracting zstd archives:
//
// tar: Child process exited with status 1
// tar: Error exit delayed from previous errors.
//
// To avoid this problem, prefer GNU tar under the name "gtar" if it is available.
try {
return await getTarVersion("gtar");
} catch {
return await getTarVersion("tar");
}
}

export interface ZstdAvailability {
available: boolean;
foundZstdBinary: boolean;
Expand All @@ -64,7 +79,7 @@ export async function isZstdAvailable(
): Promise<ZstdAvailability> {
const foundZstdBinary = await isBinaryAccessible("zstd", logger);
try {
const tarVersion = await getTarVersion("tar");
const tarVersion = await pickTarCommand();
const { type, version } = tarVersion;
logger.info(`Found ${type} tar version ${version}.`);
switch (type) {
Expand Down