Skip to content

bun install -g github:... produces broken CLI (Aborted in PGLite callMain) + blocked postinstall hides migrations #218

@gopalpatel

Description

@gopalpatel

Summary

bun install -g github:garrytan/gbrain produces a CLI where every command that opens PGLite aborts with a WASM Aborted(), even on a brand-new empty data dir. The same version installed via the documented git clone + bun install && bun link path (per INSTALL_FOR_AGENTS.md) works correctly.

Bun's security policy also silently blocks the postinstall hook (Blocked 1 postinstall. Run 'bun pm -g untrusted' for details.) so users following the "just upgrade" flow in CHANGELOG don't learn that apply-migrations never ran.

Hit this upgrading from v0.12.0 (installed yesterday via bun install -g, worked fine) → v0.12.3 (same install command, broken).

Environment

  • OS: NVIDIA DGX Spark, Linux ARM64 (Ubuntu)
  • Node: v22.22.1
  • Bun: 1.3.12
  • gbrain: 0.12.3 (commit 013b348) — also reproduces on 0.12.0 (81b3f7a) when reinstalled via the same path
  • @electric-sql/pglite: 0.4.4 (declared and resolved)

Repro (broken path)

bun install -g github:garrytan/gbrain
# "Blocked 1 postinstall. Run `bun pm -g untrusted` for details."
export PATH=$HOME/.bun/bin:$PATH
gbrain --version                # prints: gbrain 0.12.3  (looks fine)
mkdir /tmp/test-brain && cd /tmp/test-brain
gbrain init --pglite --path /tmp/test-brain/brain
# Setting up local brain with PGLite (no server needed)...
# Aborted(). Build with -sASSERTIONS for more info.

gbrain config, gbrain stats, gbrain apply-migrations --yes etc. all produce the same Aborted() once the CLI tries to open PGLite.

Works (blessed path)

bun remove -g gbrain
git clone https://github.com/garrytan/gbrain.git ~/gbrain-tmp
cd ~/gbrain-tmp && bun install && bun link
gbrain --version                # prints: gbrain 0.12.3
mkdir /tmp/test-brain-2 && cd /tmp/test-brain-2
gbrain init --pglite --path /tmp/test-brain-2/brain
# Setting up local brain with PGLite (no server needed)...
#   Migration 2 applied: slugify_existing_pages
#   ...
#   9 migration(s) applied
# Brain ready at /tmp/test-brain-2/brain

Stack trace (via bun, clean output)

RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
  at abort (.../@electric-sql/pglite/dist/index.js:1:77811)
  at invoke_viiiiii (.../dist/index.js:3:265750)
  at callMain (.../dist/index.js:3:270645)
  at at (.../dist/index.js:3:283568)
  at async create (.../dist/index.js:3:272669)

Bun v1.3.12 (Linux arm64)

Narrowing the cause

Tried each layer independently via a tiny script against the broken bun install -g node_modules:

// Directly import from the SAME node_modules path the broken CLI uses
import { PGlite } from ".../node_modules/@electric-sql/pglite/dist/index.js";
import { vector } from ".../vector/index.js";
import { pg_trgm } from ".../contrib/pg_trgm.js";
const db = await PGlite.create({ dataDir: "/tmp/x", extensions: { vector, pg_trgm } });
await db.exec(PGLITE_SCHEMA_SQL);  // full gbrain schema
// OK — no abort
  • PGlite.create({...}) with both extensions: works
  • Full PGLITE_SCHEMA_SQL applied in one db.exec(...): works
  • Instantiating PGLiteEngine directly from src/core/pglite-engine.ts in the cloned repo + full initSchema(): works — 9 migrations apply cleanly
  • Invoking via gbrain init --pglite CLI on the blessed install: works
  • Invoking via gbrain init --pglite CLI on the bun install -g install: aborts

So the PGLite layer is fine in both install paths. Something about how the CLI's entrypoint runs under bun install -g-style installation triggers the abort before the PGlite.create({...}) actually completes. My best guess: a subtle module-resolution or TS-loading difference between bun install -g github:... and bun link that corrupts the WASM init path. I didn't fully isolate it.

Suggested fixes (any one would have saved me an hour)

  1. Document that bun install -g github:... is unsupported in README / INSTALL_FOR_AGENTS. Currently there's no warning and the command "looks" like it worked.
  2. Or, make bun install -g github:... work — worth investigating what's different.
  3. First-run self-check — when gbrain starts and detects no config and/or no PGLite connect success, print an actionable message ("is your install from git clone + bun link? If you used bun install -g github:..., reinstall via the documented path").
  4. Surface blocked postinstall — right now "Blocked 1 postinstall" is shown once during install and then silent forever. CHANGELOG says gbrain upgrade "pulls it" and "the v0.12.2 orchestrator still runs on upgrade" — neither is true when postinstall is blocked. Consider printing a warning on startup when a pending migration is detected, or in gbrain --version when there's a schema gap.

Cheers — PR #196, #198, #216 are all great work. This report is "so the next person doesn't lose an hour," not a complaint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions