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)
- 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.
- Or, make
bun install -g github:... work — worth investigating what's different.
- 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").
- 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.
Summary
bun install -g github:garrytan/gbrainproduces a CLI where every command that opens PGLite aborts with a WASMAborted(), even on a brand-new empty data dir. The same version installed via the documentedgit clone + bun install && bun linkpath (perINSTALL_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 thatapply-migrationsnever ran.Hit this upgrading from v0.12.0 (installed yesterday via
bun install -g, worked fine) → v0.12.3 (same install command, broken).Environment
013b348) — also reproduces on 0.12.0 (81b3f7a) when reinstalled via the same pathRepro (broken path)
gbrain config,gbrain stats,gbrain apply-migrations --yesetc. all produce the sameAborted()once the CLI tries to open PGLite.Works (blessed path)
Stack trace (via bun, clean output)
Narrowing the cause
Tried each layer independently via a tiny script against the broken
bun install -gnode_modules:PGlite.create({...})with both extensions: worksPGLITE_SCHEMA_SQLapplied in onedb.exec(...): worksPGLiteEnginedirectly fromsrc/core/pglite-engine.tsin the cloned repo + fullinitSchema(): works — 9 migrations apply cleanlygbrain init --pgliteCLI on the blessed install: worksgbrain init --pgliteCLI on thebun install -ginstall: abortsSo 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 thePGlite.create({...})actually completes. My best guess: a subtle module-resolution or TS-loading difference betweenbun install -g github:...andbun linkthat corrupts the WASM init path. I didn't fully isolate it.Suggested fixes (any one would have saved me an hour)
bun install -g github:...is unsupported in README / INSTALL_FOR_AGENTS. Currently there's no warning and the command "looks" like it worked.bun install -g github:...work — worth investigating what's different.gbrainstarts and detects no config and/or no PGLite connect success, print an actionable message ("is your install fromgit clone + bun link? If you usedbun install -g github:..., reinstall via the documented path")."Blocked 1 postinstall"is shown once during install and then silent forever. CHANGELOG saysgbrain 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 ingbrain --versionwhen 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.