Skip to content

Commit 61c77a4

Browse files
committed
Prefer gtar if available
1 parent 4267fa6 commit 61c77a4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/tar.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ async function getTarVersion(programName: string): Promise<TarVersion> {
5353
}
5454
}
5555

56+
async function pickTarCommand(): Promise<TarVersion> {
57+
// bsdtar 3.5.3 on the macos-14 (arm) action runner image is prone to crash with the following
58+
// error messages when extracting zstd archives:
59+
//
60+
// tar: Child process exited with status 1
61+
// tar: Error exit delayed from previous errors.
62+
//
63+
// To avoid this problem, prefer GNU tar under the name "gtar" if it is available.
64+
try {
65+
return await getTarVersion("gtar");
66+
} catch {
67+
return await getTarVersion("tar");
68+
}
69+
}
70+
5671
export interface ZstdAvailability {
5772
available: boolean;
5873
foundZstdBinary: boolean;
@@ -64,7 +79,7 @@ export async function isZstdAvailable(
6479
): Promise<ZstdAvailability> {
6580
const foundZstdBinary = await isBinaryAccessible("zstd", logger);
6681
try {
67-
const tarVersion = await getTarVersion("tar");
82+
const tarVersion = await pickTarCommand();
6883
const { type, version } = tarVersion;
6984
logger.info(`Found ${type} tar version ${version}.`);
7085
switch (type) {

0 commit comments

Comments
 (0)