From fe762f6f2617daba66134ba7ef062049022e242c Mon Sep 17 00:00:00 2001 From: can1357 Date: Tue, 7 Apr 2026 05:59:42 +0200 Subject: [PATCH] fix(ci): resolve napi bin directly and allow const_for_fn on power stop - build-native.ts: bunx @napi-rs/cli was picking up Mono's /usr/bin/cli on Ubuntu runners; resolve the napi bin from node_modules/.bin instead. - power.rs: non-macOS build strips the cfg body, leaving stop() as a no-op that clippy wants const. Allow the lint since the macOS branch can't be const. --- crates/pi-natives/src/power.rs | 1 + packages/natives/scripts/build-native.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/pi-natives/src/power.rs b/crates/pi-natives/src/power.rs index 59fd381e4..4a8df4f96 100644 --- a/crates/pi-natives/src/power.rs +++ b/crates/pi-natives/src/power.rs @@ -191,6 +191,7 @@ impl MacOSPowerAssertion { /// Release the power assertion early. #[napi] + #[allow(clippy::missing_const_for_fn, reason = "not const on macOS")] pub fn stop(&mut self) -> napi::Result<()> { #[cfg(target_os = "macos")] if let Some(inner) = &mut self.inner { diff --git a/packages/natives/scripts/build-native.ts b/packages/natives/scripts/build-native.ts index 764d32dc2..486ec1966 100644 --- a/packages/natives/scripts/build-native.ts +++ b/packages/natives/scripts/build-native.ts @@ -171,7 +171,15 @@ console.log(`Building pi-natives for ${targetPlatform}-${targetArch}${variantSuf await fs.mkdir(nativeDir, { recursive: true }); await cleanupStaleTemps(nativeDir); -const buildResult = await $`bunx @napi-rs/cli ${napiArgs}`.nothrow(); +// Resolve napi bin directly: `bunx @napi-rs/cli` can pick up the wrong bin on +// systems where `cli` exists on PATH (e.g. Mono's /usr/bin/cli on Ubuntu). +const napiBin = Bun.which("napi", { + PATH: `${path.join(import.meta.dir, "..", "node_modules", ".bin")}:${path.join(repoRoot, "node_modules", ".bin")}:${process.env.PATH ?? ""}`, +}); +if (!napiBin) { + throw new Error("Could not locate @napi-rs/cli `napi` binary in node_modules/.bin"); +} +const buildResult = await $`${napiBin} ${napiArgs}`.nothrow(); if (buildResult.exitCode !== 0) { const stderr = buildResult.stderr?.toString("utf-8") ?? ""; throw new Error(`napi build failed${stderr ? `:\n${stderr}` : ""}`);