fix: catch spawn failures in the macOS purge workaround (#403)

@actions/exec loses errors thrown synchronously by spawn (e.g. EPERM on
sandboxed runners), so the try/catch never fires and the post step exits
before saving the cache. execFile passes them to the caller.
This commit is contained in:
Nathaniel McCallum
2026-11-14 09:16:55 +01:00
committed by GitHub
parent c8037a86dd
commit f4371d1ec7
+3 -2
View File
@@ -1,5 +1,6 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import { execFile } from "child_process";
import { promisify } from "util";
import { cleanBin, cleanGit, cleanRegistry, cleanTargetDir } from "./cleanup.js";
import { CacheConfig, isCacheUpToDate } from "./config.js";
@@ -94,6 +95,6 @@ async function macOsWorkaround() {
try {
// Workaround for https://github.com/actions/cache/issues/403
// Also see https://github.com/rust-lang/cargo/issues/8603
await exec.exec("sudo", ["/usr/sbin/purge"], { silent: true });
await promisify(execFile)("sudo", ["/usr/sbin/purge"]);
} catch {}
}