`gstack-config gbrain-refresh` on Windows always reports `local-status: unknown` — Windows Python cannot open the MSYS-style detection-file path
- Dominant language
- TypeScript
- Stars
- 133k
- Forks
- 19.9k
- Avg merge
- 18h 46m
- Merged PRs (30d)
- 26
Description
## Environment
- Windows 11, Git Bash (MSYS2)
- gstack v1.57.9.0, global-git install at `~/.claude/skills/gstack`
- `python3` resolves to the native Windows Python (`/c/Users//AppData/Local/Microsoft/WindowsApps/python3`)
- gbrain 0.35.8.0, PGLite engine, fully healthy (`gbrain doctor` ok, `gbrain sources list --json` exits 0)
## Symptom
`gstack-config gbrain-refresh` always bails with:
```
gbrain not detected (local-status: unknown) → brain-aware blocks will be suppressed in planning-skill SKILL.md files.
```
…even though the detection file it just wrote (`~/.gstack/gbrain-detection.json`) contains `"gbrain_local_status": "ok"`. The render step is never reached, so the new-in-1.57.9.0 brain-aware blocks can't be enabled on Windows via the documented command.
## Root cause
`bin/gstack-config` (gbrain-refresh case, ~line 388) parses the detection JSON with:
```sh
STATUS=$("$PYTHON_CMD" -c "import json,sys; d=json.load(open('$DETECTION_FILE')); print(d.get('gbrain_local_status','unknown'))" 2>/dev/null || echo unknown)
```
`$DETECTION_FILE` is an MSYS-style path (`/c/Users//.gstack/gbrain-detection.json`). `command -v python3 || command -v python` finds **native Windows Python**, which does not understand `/c/...` paths and raises `FileNotFoundError`. The `2>/dev/null` swallows the traceback, the `|| echo unknown` kicks in, and `STATUS=unknown` falls through to the "not detected" branch.
Repro (any Windows box with Git Bash + Windows Python):
```sh
$ python3 -c "import json; json.load(open('/c/Users//.gstack/gbrain-detection.json'))"
FileNotFoundError: [Errno 2] No such file or directory: '/c/Users//.gstack/gbrain-detection.json'
```
The grep fallback a few lines down would have parsed the file correctly, but it's only used when no Python is found.
## Suggested fix (any of)
1. On Windows/MSYS, convert the path first: `DETECTION_FILE_NATIVE=$(cygpath -w "$DETECTION_FILE" 2>/dev/null || echo "$DETECTION_FILE")` and pass that to Python.
2. Prefer the existing grep fallback over Python (it's sufficient for these two flat string fields and has no path-translation problem).
3. Parse with `bun` instead — it's already a hard requirement for the render step in the same code path, and Bun handles MSYS paths fine.
## Workaround
`cd ~/.claude/skills/gstack && bun run gen:skill-docs:user --host claude` renders the brain-aware blocks correctly (gen-skill-docs reads the detection file itself via `--respect-detection` and isn't affected).
## Adjacent (separate) issue, mentioning for context
On the same machine, the `freshClassify` probe (`lib/gbrain-local-status.ts`, `PROBE_TIMEOUT_MS = 5_000`) intermittently times out on a 633MB PGLite brain's cold open and caches a false `broken-config` for the TTL window — which is what `./setup` hits when it prints "gbrain not detected" during install. `--no-cache` immediately returns `ok`. That looks like another flavor of #1792 (probe misclassifies a healthy brain); happy to file separately with timings if useful.
Contributor guide
Assessment
This issue has not been assessed yet.