gemini-cli - ✅(Solved) Fix bug: build scripts hardcode npm — bun install fails in scripts/build.js [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#26279Fetched 2026-05-01 05:52:51
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
cross-referenced ×1labeled ×1renamed ×1

Running bun install on a Bun-only system (no npm on PATH) fails because the prepare script chain invokes scripts/build.js, which uses npm unconditionally for install, run generate, and workspace builds. A second hardcoded npm reference in scripts/build_package.js blocks the per-workspace build of @google/gemini-cli-core.

This issue covers the script-level npm hardcoding — fixing it lets scripts/build.js and scripts/build_package.js run cleanly under Bun. The root package.json bundle script also has Bun-incompatible workspace flag usage (-w, --workspace=) that this issue does not address; that's a separate concern for a follow-up.

Error Message

$ bun install bun install v1.3.13 (bf2e2cec) warn: Bun currently does not support nested "overrides" Saved lockfile

$ husky && bun run bundle $ bun run generate && bun run build --workspace=@google/gemini-cli-devtools && ... $ node scripts/build.js "--workspace=@google/gemini-cli-devtools" /bin/sh: 1: npm: not found error: Command failed: npm run generate

Root Cause

scripts/build.js hardcodes npm at lines 30, 34, 38, 42, 50, 57. scripts/build_package.js hardcodes it at line 38 (npm run bundle:browser-mcp for the core package's chrome devtools MCP bundling). All of these run during bun install's prepare chain.

Fix Action

Fixed

PR fix notes

PR #26280: fix(build): detect Bun runtime in build scripts to avoid hardcoded npm

Description (problem / solution / changelog)

Summary

scripts/build.js, scripts/build_package.js, and the husky pre-commit hook all invoke npm unconditionally. This breaks bun install and committing on Bun-only systems (where npm is not on PATH), because the prepare script chain runs scripts/build.js and the pre-commit hook fires on every commit.

Detect the runtime so the equivalent bun command is used when bun is available and npm is not. The npm code paths are unchanged for npm users.

Changes

  • scripts/build.js: detect Bun via 'bun' in process.versions. Under Bun, use bun install / bun run generate / bun run --filter '*' build. The existing npm + npm-run-all parallel path is left exactly as-is for npm users (CI-vs-non-CI branches included).
  • scripts/build_package.js: same process.versions.bun check for the chrome devtools MCP bundle step in @google/gemini-cli-core.
  • .husky/pre-commit: detect via command -v npm. npm users keep their exact existing behaviour; bun-only systems fall through to bun run pre-commit.

Out of scope

The root package.json bundle script still uses npm-style workspace flags (-w, --workspace=) that bun handles differently. So bun install will still fail further downstream of this fix at the bundle step. That's tracked separately as it requires a structural change to package.json scripts; this PR is scoped to the script-level npm hardcoding called out in the issue.

Test plan

  • On a Bun-only system (no npm), node scripts/build.js runs through to per-workspace builds successfully (failing only at the package.json bundle step noted above)
  • git commit no longer fails immediately due to npm: not found — pre-commit lint-staged runs under bun
  • On a system with npm, all behaviour is unchanged (the npm branches are character-identical to before; verified by reading the diff)
  • Reviewer note: this is a scoped re-do of the script-level portion of the auto-closed #22341, with the Fixes #26279 link present from minute zero so the issue-link bot doesn't auto-close it again.

Fixes #26279

Changed files

  • .husky/pre-commit (modified, +3/-1)
  • scripts/build.js (modified, +31/-4)
  • scripts/build_package.js (modified, +10/-3)

Code Example

$ bun install
bun install v1.3.13 (bf2e2cec)
warn: Bun currently does not support nested "overrides"
Saved lockfile

$ husky && bun run bundle
$ bun run generate && bun run build --workspace=@google/gemini-cli-devtools && ...
$ node scripts/build.js "--workspace=@google/gemini-cli-devtools"
/bin/sh: 1: npm: not found
error: Command failed: npm run generate
RAW_BUFFERClick to expand / collapse

Summary

Running bun install on a Bun-only system (no npm on PATH) fails because the prepare script chain invokes scripts/build.js, which uses npm unconditionally for install, run generate, and workspace builds. A second hardcoded npm reference in scripts/build_package.js blocks the per-workspace build of @google/gemini-cli-core.

This issue covers the script-level npm hardcoding — fixing it lets scripts/build.js and scripts/build_package.js run cleanly under Bun. The root package.json bundle script also has Bun-incompatible workspace flag usage (-w, --workspace=) that this issue does not address; that's a separate concern for a follow-up.

Reproduction

  1. System with bun but no npm on PATH (e.g. curl -fsSL https://bun.sh/install | bash, no Node.js)
  2. Clone google-gemini/gemini-cli
  3. Run bun install

Observed

$ bun install
bun install v1.3.13 (bf2e2cec)
warn: Bun currently does not support nested "overrides"
Saved lockfile

$ husky && bun run bundle
$ bun run generate && bun run build --workspace=@google/gemini-cli-devtools && ...
$ node scripts/build.js "--workspace=@google/gemini-cli-devtools"
/bin/sh: 1: npm: not found
error: Command failed: npm run generate

Root cause

scripts/build.js hardcodes npm at lines 30, 34, 38, 42, 50, 57. scripts/build_package.js hardcodes it at line 38 (npm run bundle:browser-mcp for the core package's chrome devtools MCP bundling). All of these run during bun install's prepare chain.

Expected

scripts/build.js and scripts/build_package.js should detect the runtime via 'bun' in process.versions and use Bun-equivalent commands when invoked under Bun, while leaving the npm path unchanged for npm users.

Environment

  • Bun 1.3.13
  • Linux x64
  • No npm available

Notes

A previous larger Bun-compatibility PR (#22341) covered these fixes among others, but was auto-closed by the issue-link bot before review and never reopened. This issue narrows scope to just the script-level fixes.

extent analysis

TL;DR

Modify scripts/build.js and scripts/build_package.js to conditionally use Bun-equivalent commands when invoked under Bun.

Guidance

  • Check the process.versions object to detect if the runtime is Bun, and use Bun commands instead of npm when it is.
  • Update lines 30, 34, 38, 42, 50, 57 in scripts/build.js to use Bun commands conditionally.
  • Update line 38 in scripts/build_package.js to use the Bun equivalent of npm run bundle:browser-mcp.
  • Verify the changes by running bun install and checking for any errors related to npm not found.

Example

if ('bun' in process.versions) {
  // Use Bun commands
  bun.run('generate');
  bun.run('build');
} else {
  // Use npm commands
  require('child_process').exec('npm run generate');
  require('child_process').exec('npm run build');
}

Notes

This fix only addresses the script-level npm hardcoding and does not cover the root package.json bundle script issues.

Recommendation

Apply workaround: Modify the scripts to conditionally use Bun commands to ensure compatibility with Bun-only systems.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING