Skip to content

fix(ci): drop redundant better-sqlite3 rebuild in CLI Linux build#4049

Merged
saddlepaddle merged 1 commit into
mainfrom
fix/cli-linux-x64-better-sqlite3-rebuild
May 4, 2026
Merged

fix(ci): drop redundant better-sqlite3 rebuild in CLI Linux build#4049
saddlepaddle merged 1 commit into
mainfrom
fix/cli-linux-x64-better-sqlite3-rebuild

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 4, 2026

Why

The cli-v0.2.4 release just bricked on linux-x64 (run 25340826401) at the Install dependencies (Linux) step:

npm error path .../node_modules/.bun/better-sqlite3@12.6.2/.../better-sqlite3
npm error command failed
npm error command sh -c prebuild-install || node-gyp rebuild --release
npm error prebuild-install warn install ENOENT: ...build/Release/better_sqlite3.node
npm error gyp: ...build/config.gypi not found while reading includes of binding.gyp
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: `gyp` failed with exit code: 1

Same step has bricked before with a different mode each time:

tag mode
cli-v0.2.4 prebuild-install ENOENT then gyp config.gypi missing
cli-v0.2.2 prebuild-install file too short then gyp EEXIST on python3 symlink
cli-v0.2.3 succeeded
cli-v0.2.1 / 0.2.0 succeeded

prebuild-install is intermittently mis-extracting / failing the download, and when it falls through to node-gyp rebuild --release the leftover state breaks the gyp run.

What changes

Remove npm rebuild better-sqlite3 from the Linux install step. It was redundant: packages/cli/scripts/build-dist.ts:282-297 (fixNativeBinariesForNode) already does

const bsqUrl =
  `https://github.com/WiseLibs/better-sqlite3/releases/download/` +
  `v${bsqVersion}/better-sqlite3-v${bsqVersion}-node-v${NODE_ABI}-${target}.tar.gz`;
...
rmSync(bsqDest, { recursive: true, force: true });
mkdirSync(bsqDest, { recursive: true });
cpSync(join(tmp, "build", "Release", "better_sqlite3.node"), join(bsqDest, "better_sqlite3.node"));

— it unconditionally fetches the Node-ABI prebuild from GitHub releases and overwrites lib/node_modules/better-sqlite3/build/Release/better_sqlite3.node in the dist. Whatever npm rebuild produced was just thrown away.

node-pty rebuild stays (no Linux prebuilds ship in the npm package — node-pty really is compiled from source). @parcel/watcher rebuild also stays for now (haven't seen it flake; out of scope).

Test plan

  • CI green on this PR (Linux build invoked via build-cli.yml from ci.yml)
  • After merge, retry the CLI release — re-cut a release PR + push the tag, or temporarily run release-cli.yml via workflow_dispatch on main to verify all three matrix targets land artifacts
  • Confirm the smoke-test require('better-sqlite3') still passes against the bundled Node — that's what proves fixNativeBinariesForNode's GitHub fetch produced a usable binary

Summary by cubic

Remove npm rebuild better-sqlite3 from the CLI Linux build to stop flaky linux-x64 failures. The dist step already fetches and overwrites the correct better-sqlite3 prebuild via fixNativeBinariesForNode().

  • Bug Fixes
    • Dropped the redundant better-sqlite3 rebuild that triggered intermittent prebuild-install/node-gyp errors.
    • Kept node-pty and @parcel/watcher rebuilds; node-pty requires source build on Linux and watcher remains unchanged.

Written for commit a71b7dc. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Improved Linux build process stability by optimizing dependency installation and native module compilation, reducing CI build failures on Linux systems.

build-dist.ts's fixNativeBinariesForNode() already downloads the matching
Node-ABI better-sqlite3 prebuild from GitHub releases and overwrites
build/Release/better_sqlite3.node unconditionally, so running
`npm rebuild better-sqlite3` in the CI install step is wasted work whose
only effect is to introduce flake.

Recent runs:
- cli-v0.2.4: prebuild-install ENOENT → gyp config.gypi missing → fail
- cli-v0.2.2: prebuild-install file too short → gyp EEXIST symlink → fail
- cli-v0.2.3: succeeded
- cli-v0.2.0/0.2.1: succeeded

linux-arm64 doesn't hit this because it follows the same path but better-
sqlite3's prebuild-install download apparently lands cleanly on arm64; the
flake is linux-x64 specific. Either way, neither needs the rebuild — the
final binary in the tarball comes from build-dist's GitHub-release fetch.

node-pty rebuild stays (no Linux prebuilds ship in the npm package).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5a66dcf9-3848-44b6-8b6b-90f714aca29b

📥 Commits

Reviewing files that changed from the base of the PR and between 07d28b7 and a71b7dc.

📒 Files selected for processing (1)
  • .github/workflows/build-cli.yml

📝 Walkthrough

Walkthrough

The Linux dependency-install step in the CLI build workflow now uses bun install --frozen --ignore-scripts followed by selective node-gyp rebuilds of node-pty, removing the unconditional npm rebuild better-sqlite3. Comments clarify that better-sqlite3 rebuilding is intentionally deferred to build-dist.ts and that the previous approach caused CI flakes.

Changes

CLI Build Workflow Optimization

Layer / File(s) Summary
Dependency Installation & Selective Rebuilds
.github/workflows/build-cli.yml
Replaces unconditional npm rebuild better-sqlite3 with bun install --frozen --ignore-scripts and explicit node-gyp rebuild for node-pty. Adds explanatory comments documenting that better-sqlite3 rebuilding is deferred to build-dist.ts (which handles Node-ABI prebuild downloads) and that prior unconditional rebuilds were a CI flake source on Linux. Includes set -euo pipefail safeguard.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit's tale of CI made bright,
No flakes on Linux, builds run tight,
Better-sqlite waits its proper turn,
While node-pty rebuilds—now we learn!
Comments guide us, step by step,
This workflow's fixed with careful prep. 🏗️

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-linux-x64-better-sqlite3-rebuild

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@saddlepaddle saddlepaddle merged commit c6db8ec into main May 4, 2026
8 of 9 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 4, 2026

Greptile Summary

Removes the npm rebuild better-sqlite3 step from the Linux CI install step, which was both redundant and a flake source. The fixNativeBinariesForNode() function in build-dist.ts already unconditionally fetches the correct Node-ABI prebuild from GitHub releases and overwrites the binary, so anything produced by the rebuild was discarded anyway. The existing smoke test (require('better-sqlite3')) provides a safety net confirming the final binary still loads correctly.

Confidence Score: 5/5

Safe to merge — the removed step was provably redundant and the smoke test validates the resulting binary.

Single-line deletion with thorough justification backed by the source code of fixNativeBinariesForNode(). The existing smoke test exercises require('better-sqlite3') post-build, providing a direct regression guard. No logic changes, only CI workflow cleanup.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/build-cli.yml Removes the redundant npm rebuild better-sqlite3 step from the Linux install and adds detailed comments explaining why it was redundant; all other rebuilds remain intact.

Sequence Diagram

sequenceDiagram
    participant CI as GitHub Actions (Linux)
    participant Bun as bun install
    participant NPM as npm rebuild
    participant Script as build-dist.ts fixNativeBinariesForNode()
    participant GH as GitHub Releases

    CI->>Bun: bun install --frozen --ignore-scripts
    Bun-->>CI: deps installed (scripts skipped)
    CI->>NPM: npx node-gyp rebuild (node-pty)
    NPM-->>CI: node-pty.node compiled
    note over CI,NPM: better-sqlite3 rebuild REMOVED (was redundant + flaky)
    CI->>NPM: npm rebuild @parcel/watcher
    NPM-->>CI: watcher.node compiled
    CI->>Script: bun run build:dist
    Script->>GH: curl better-sqlite3 Node-ABI tarball
    GH-->>Script: better_sqlite3.node prebuild
    Script->>Script: overwrite lib/node_modules/better-sqlite3/build/Release/
    Script-->>CI: dist/ artifact ready
    CI->>CI: Smoke test: require('better-sqlite3') OK
Loading

Reviews (1): Last reviewed commit: "fix(ci): drop redundant npm rebuild bett..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant