From f4371d1ec7179bfbd04a82a81e3b3af7f720750f Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum Date: Sat, 14 Nov 2026 08:16:55 +0000 Subject: [PATCH] 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. --- src/save.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/save.ts b/src/save.ts index dae4a27..4f1c3c4 100644 --- a/src/save.ts +++ b/src/save.ts @@ -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 {} }