garrytan / garrytan/gstack

Windows: `gstack-gbrain-sync.ts` stage 3 fails to spawn `gstack-brain-sync` (`spawnSync` needs `shell: true`)

Open
#1,731 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
133k
Forks
19.9k
Avg merge
18h 46m
Merged PRs (30d)
26

Description

## Summary

On Windows (Git Bash + Bun runtime), stage 3 of the unified `gstack-gbrain-sync.ts` (the `brain-sync` stage for curated artifacts → git pipeline) fails with `gstack-brain-sync exited undefined`. Functional impact is limited (running `gstack-brain-sync` directly works fine), but the noise pollutes the sync summary on every gstack skill start and makes real errors harder to spot.

## Environment

- **OS:** Windows 11
- **Shell:** Git Bash (MSYS2)
- **gstack version:** `1.45.0.0`
- **Bun version:** (Bun-bundled with gstack install)
- **gbrain version:** `0.18.2`

## Root cause

`bin/gstack-gbrain-sync.ts:964-971` — the `runBrainSyncPush` function uses:

```ts
spawnSync(brainSyncPath, ["--once"], { stdio: [...], timeout: 60000 })
```

— without `shell: true`.

`gstack-brain-sync` is a bash-shebang script:

```bash
#!/usr/bin/env bash
```

Windows can't `exec` a shebang file directly without going through a shell. So `spawnSync` fails to spawn (returns `result.status === undefined`), and the wrapper interprets that as a stage failure.

## Reproduction

On any Windows machine with gstack installed + gbrain configured:

```bash
# In Git Bash
gstack-gbrain-sync --incremental
```

Expected: stage 3 completes cleanly.
Actual: stage 3 reports `gstack-brain-sync exited undefined`, even though running `gstack-brain-sync --once` directly works (exits 0, empty queue).

## Proposed fix

Add `shell: true` to both `spawnSync` calls in `runBrainSyncPush`, OR wrap with explicit `bash` invocation on Windows:

```ts
// Option A — simple:
spawnSync(brainSyncPath, ["--once"], { stdio: [...], timeout: 60000, shell: true })

// Option B — explicit cross-platform:
const isWindows = process.platform === "win32";
const cmd = isWindows ? "bash" : brainSyncPath;
const args = isWindows ? [brainSyncPath, "--once"] : ["--once"];
spawnSync(cmd, args, { stdio: [...], timeout: 60000 });
```

## Workaround currently in use

`gstack-gbrain-sync --no-brain-sync` to skip stage 3 explicitly. Functional but noisy in the sync summary.

## Discovered by

Surfaced by Harry Malinski (@hmalinski) during a Liquid Acre dev-machine cleanup session on 2026-05-26 after upgrading gstack 1.35.0.0 → 1.45.0.0. Logged in the LA project's observations log (`docs/orchestration/_observations-log.md`, session 2026-05-26 afternoon, obs #4).

Related context: a separate `gstack-memory-ingest` Windows incompat from gstack 1.35.x was **already fixed in 1.45.0.0** — same session confirmed that stage works cleanly now. This `runBrainSyncPush` gap appears to be the last remaining Windows-spawn issue in the unified sync.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.