Skip to content

PGLite WASM initialization fails with ENOENT: //root/pglite.data on macOS 12.7.6 + Bun 1.3.14 #1340

@788s4jnmgr-cloud

Description

@788s4jnmgr-cloud

Bug Description

PGLite-based gbrain commands crash immediately with:

PGLite failed to initialize its WASM runtime.
  This is most commonly the macOS 26.3 WASM bug: https://github.com/garrytan/gbrain/issues/223
  Run \`gbrain doctor\` for a full diagnosis.
  Original error: ENOENT: no such file or directory, open '/$$bunfs/root/pglite.data'.

Unlike issue #223 (which is macOS 26.3 specific), this occurs on macOS 12.7.6 (Darwin 21H1320).

Steps to Reproduce

  1. `gbrain sync --skip-failed`
  2. `gbrain sources list`
  3. `gbrain apply-migrations --yes`
  4. Any command that triggers `engine.connect()`

All crash with the same PGLite WASM initialization error.

Commands that work: `gbrain doctor --fast` (skips DB connection check).

Environment

  • macOS: 12.7.6 (Darwin 21H1320, macOS Monterey)
  • Bun: 1.3.14
  • Node: v24.14.1
  • gbrain: 0.40.8.0 (source build) and 0.40.2.0 (official binary)
  • PGLite: 0.4.3
  • Architecture: arm64 (Apple Silicon)

Analysis

The error path `/$$bunfs/root/pglite.data` is a Bun virtual filesystem mount point. On this macOS version, `/$$bunfs/root` is a read-only directory:

$ ls / | grep bunfs
# → nothing (directory does not exist or is empty/mounted as read-only)

$ mkdir -p /$$bunfs/root
# → mkdir: /$$bunfs: Read-only file system

This means PGLite cannot write its `pglite.data` file during `PGlite.create()`, causing immediate Abort.

`gbrain doctor` works because the `--fast` flag skips the DB connection phase entirely.

Expected Behavior

PGLite should initialize successfully, or gbrain should detect this path issue and fall back gracefully.

Additional Context

  • Issue PGLite WASM crash on macOS 26.3 with Bun 1.3.11 #223 mentions macOS 26.3, but this machine is on macOS 12.7.6
  • Tested with both official gbrain binary (0.40.2.0) and source-built binary (0.40.8.0) — both fail
  • Tested with `bun run src/cli.ts` (direct source) — also fails
  • `/$$bunfs/root` being read-only appears to be the root cause

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