Skip to content
TypeScript

fix(grok): Grok updates actually install on npm 12 (#24246)

Ishaan Kothari3e2dff420664
diff --git a/packages/provider-grok/src/server/driver.test.ts b/packages/provider-grok/src/server/driver.test.ts
index 958dcdfa545..3a080ec6058 100644
--- a/packages/provider-grok/src/server/driver.test.ts
+++ b/packages/provider-grok/src/server/driver.test.ts
@@ -117,6 +117,8 @@ it.layer(layerTest)("GrokDriver", (it) => {
executable: binaryPath,
args: ["update"],
lockKey: "grok",
+ // npm 12 otherwise skips the postinstall that installs the new binary.
+ env: expect.objectContaining({ npm_config_allow_scripts: "@xai-official/grok" }),
}),
},
] as const;
diff --git a/packages/provider-grok/src/server/driver.ts b/packages/provider-grok/src/server/driver.ts
index 84cc590c545..acb8690509e 100644
--- a/packages/provider-grok/src/server/driver.ts
+++ b/packages/provider-grok/src/server/driver.ts
@@ -50,6 +50,7 @@ const DRIVER_KIND = ProviderDriverKind.make("grok");
// npm latest matches the stable channel installed by grok update.
const GROK_NPM_PACKAGE = "@xai-official/grok";
// `grok update` installs under `GROK_HOME`; use the resolved executable and instance environment.
+// npm 12 blocks the postinstall that moves the new binary in, yet exits 0, so allow it by env.
// Homebrew casks need brew upgrades; `grok update` would install a second copy.
// Keep casks manual when their brew cannot vouch for them.
const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
@@ -83,7 +84,7 @@ const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
updateArgs: ["update"],
updateLockKey: "grok",
platform: context.platform,
- env: context.env,
+ env: { ...context.env, npm_config_allow_scripts: GROK_NPM_PACKAGE },
});
}),
};