From 9a52d96cece6f9ae9cd04df43b674521363e87c1 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 25 Oct 2026 14:54:22 +0800 Subject: [PATCH] gcp-ai: the tests' fake gcloud runs on the test's own runtime, not PATH's node publish.yml has been red since e801e43 (#307): 20 gcp-ai tests fail with "gcloud could not read Google Cloud credentials or configuration". CI runs every package in one bun process from the repo root. grok's nocli.mjs sets PATH to /usr/bin:/bin for the rest of that process, and setup-node's node is not there, so the fake gcloud's `#!/usr/bin/env node` could not start. Run alone, gcp-ai passed, which is how the merge was verified. The fake's shebang now names process.execPath. The fake stays pinned by path in each test and CLOUDSDK_CONFIG stays under the test's own HOME. Run: `bun test packages/grok packages/gcp-ai` from the repo root, with HOME a sandbox dir and the network pointed at 127.0.0.1:9: 20 fail before (the CI list, plus "closing a login waits..." at its 30s bar), 122 pass 0 fail after. Full root run `HOME= bun test` and `bun scripts/check.mjs` at the pushed head: see below. Linux: the 5 browser tests pass in oven/bun:1.4.2 with apt chromium (--no-sandbox wrapper through VERTEX_CHROME_PATH), the passive sign-in one in 11s. --- packages/gcp-ai/test/gcloud.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/gcp-ai/test/gcloud.mjs b/packages/gcp-ai/test/gcloud.mjs index 59c1f77..dc7c0c8 100644 --- a/packages/gcp-ai/test/gcloud.mjs +++ b/packages/gcp-ai/test/gcloud.mjs @@ -15,7 +15,11 @@ export async function fakeGcloud() { // sides meet at $HOME/.config/gcloud: the fake gcloud writes there, and so // does the plugin's own account directories stay out of it. const sdk = join(directory, ".config", "gcloud") - await writeFile(join(directory, "gcloud"), `#!/usr/bin/env node + // The fake runs on this test's own runtime, named by path: another + // package's tests in the same run may leave PATH without node (grok's + // nocli.mjs keeps only /usr/bin and /bin), and setup-node's node is not + // there on CI. + await writeFile(join(directory, "gcloud"), `#!${process.execPath} import { appendFileSync, readFileSync } from "node:fs" import { join } from "node:path" const state = JSON.parse(readFileSync(process.env.VERTEX_TEST_GCLOUD, "utf8"))