gstack icon indicating copy to clipboard operation
gstack copied to clipboard

setup fails on Linux: build-node-server.sh uses unescaped { in perl regex (fatal on perl ≥5.26)

Open kapioskapiou opened this issue 4 months ago • 1 comments

setup fails on Linux: build-node-server.sh uses unescaped { in perl regex (fatal on perl ≥5.26)

Summary

./setup aborts on a fresh Linux install because browse/scripts/build-node-server.sh runs a perl substitution whose pattern contains an unescaped literal {. Perl 5.26+ treats an unescaped { in a regex as a fatal error, so perl exits non-zero, and because the script runs under set -e, the entire gstack setup aborts.

Notably this is a Windows-only build step (Node.js server bundle, per the script header), so it should never block setup on Linux/macOS at all.

Environment

  • OS: AlmaLinux 8.10 (Cerulean Leopard), x86_64
  • perl: v5.26.3
  • bun: 1.3.14

Offending line

browse/scripts/build-node-server.sh:35

perl -pi -e 's|import { Database } from "bun:sqlite";|const Database = null; // bun:sqlite stubbed on Node|g' "$DIST_DIR/server-node.mjs"

Error

Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/import { <-- HERE Database } .../ at -e line 1.

This surfaces to the user as:

script "build" exited with code 255
gstack setup failed

Root cause

In perl 5.26.0 the previously-deprecated unescaped literal { inside a regex pattern became a hard error. The { / } in import { Database } are parsed as a (malformed) quantifier and rejected.

Fix

Escape the braces in the pattern (behavior-preserving):

perl -pi -e 's|import \{ Database \} from "bun:sqlite";|const Database = null; // bun:sqlite stubbed on Node|g' "$DIST_DIR/server-node.mjs"

Secondary issue (worth considering)

This bundle step is documented as Windows-only, yet it runs unconditionally during setup and, under set -e, a failure here kills the whole install. Consider either:

  • guarding the Node/Windows bundle build behind an OS/platform check, or
  • not letting a failure in this optional step abort the top-level setup.

That would make setup resilient even if a future regex/tooling incompatibility resurfaces.

kapioskapiou avatar Jul 19 '26 00:07 kapioskapiou

Confirming this reproduces on Windows too, not just Linux — and on Windows it's more than a nuisance, because browse/scripts/build-node-server.sh is explicitly the Windows-only Node.js server bundle build step (Bun can't drive Playwright Chromium on Windows, so browse runs server-node.mjs under Node there). When this perl step fails silently mid-build, the result is a server-node.mjs that still has the raw bun:sqlite import and no polyfill header — so instead of a setup abort, we get a working install that later fails at runtime with:

[browse] Starting server...
[browse] Server failed to start within 15s

Same fix works (s|import \{ Database \} from "bun:sqlite";|...|), confirmed against browse/dist/browse.exe status → healthy after manually patching + rebuilding.

Why this needs the upstream fix specifically, not just a documented workaround: /gstack-upgrade runs git reset --hard origin/main, which wipes any local patch to build-node-server.sh on every upgrade. We've now hit this exact failure across two separate sessions on the same machine, weeks apart — each time requiring re-diagnosing "why won't browse start" back down to this line, because the fix doesn't survive an upgrade. Would be great to get this landed so Windows users stop losing browse on every upgrade.

Happy to test a patched build if useful.

akhanaton avatar Jul 21 '26 11:07 akhanaton