Repository navigation
TypeScript hooks start under a Windows home with an apostrophe, or with MSYS path conversion off - #4386
TypeScript hooks start under a Windows home with an apostrophe, or with MSYS path conversion off#4386abyss-node wants to merge 1 commit into
Conversation
…th MSYS path conversion off Git Bash rewrites a /c/x argument to C:/x when it starts a native program, but msys2-runtime leaves any argument holding ' ` [ ] unconverted (winsup/cygwin/msys2_path_conv.cc), and MSYS_NO_PATHCONV=1 leaves them all. Every TypeScript hook shim spells its own directory with pwd, so bun.exe got /c/x, which it cannot open. Under a home such as C:\Users\O'Brien all 13 shims died with "Module not found" before their entry ran (the /autoplan Read barrier answered every Read with its "hook unavailable" deny), and gstack-hook-check reported all 12 registered TypeScript hooks as "bun could not bundle the TypeScript entry", so setup refused to register them. Each shim now converts its directory with cygpath -m under the OSTYPE and cygpath test that already picks GSTACK_BUN_CONFIG, and gstack-hook-check hands Bun its entries the same way. Off a Windows bash, or with no cygpath on PATH, both are no-ops. test/setup-hook-syntax-gate.test.ts runs the checker and every TypeScript hook shim from a root with an apostrophe: for real on Windows (also with MSYS_NO_PATHCONV=1), and through a simulated Windows bash on POSIX. AGENTS.md states the rule for new shims. Verified: upstream bin/gstack-hook-check on a gstack tree under a home with an apostrophe (Windows 11, Git Bash) -> exit 1, 12 of 12 TypeScript hooks fail; same tree through a junction with no apostrophe -> exit 0, 15 ok Verified: fixed bin/gstack-hook-check on that tree -> exit 0, 15 ok, 0 fail; also with MSYS_NO_PATHCONV=1 and with MSYS2_ARG_CONV_EXCL=* -> 15 ok, 0 fail Verified: fixed checker with a planted TypeScript syntax error under the same root -> exit 1, fail <file>.ts:35: Unexpected ; Verified: all 13 shims run through /bin/sh -c with hook JSON on stdin -> before 13/13 "Module not found"; after 13/13 exit 0, rows identical to the no-apostrophe junction, mode-handoff-hook prints its systemMessage Verified: bun test --timeout 120000 test/setup-hook-syntax-gate.test.ts on Windows (bun 1.4.4-canary) -> fixed 17 pass 3 fail, unfixed 15 pass 5 fail; the two new tests are the only difference Verified: bun test test/setup-hook-syntax-gate.test.ts on Linux (WSL2 Ubuntu, bun 1.4.4) -> fixed 22 pass 0 fail; unfixed 20 pass, the two new tests fail Verified: bun test test/bun-entry-isolation.test.ts -t "shell callers|detector|config-definition" and test/ceo-mode-handoff-hook.test.ts on Linux -> 4/4 and 4/4 pass Verified: the conversion line under OSTYPE=linux-gnu or darwin23, and under OSTYPE=msys with no cygpath on PATH -> HERE unchanged Unverified: the full suite; the runs used a 162-file partial upstream tree (git clone of the repo was not possible on this network) Unverified: the 3 Windows setup-section failures, present with and without this change, come from the harness single-quoting a bun path that itself holds an apostrophe on the test machine Unverified: macOS and Cygwin runs; the simulated-bash tests realpath their root for macOS /private/var
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Thank you for the careful root-cause work and the simulated Windows bash in the test. Windows has minimal support in gstack, but we do keep hooks and startup working there, and this breaks every TypeScript hook for anyone with path conversion off or an apostrophe in their path. So we're taking it as a small fix: a maintainer agent will rebuild it on current main with you credited as co-author, and close this PR with a link once it lands. The rebuild will likely leave out the AGENTS.md line and keep the change to the hook shims, |
|
Checked current main (f71e785, 1.102.1.0) on Windows under a home path with an apostrophe: |
|
Thanks for checking current main on Windows, and sorry for the wait. Yes, it's still queued, and it's now the first item in a batch of fixes a maintainer agent is starting (our tracking thread GSTA-801). We've labelled it S2 because |
|
Thanks! One note for the repro: #4386 only covers the hooks. On current main, |
|
Thank you for the root-cause work and the simulated Git Bash test. A rebuild of this landed on main in #4682, with you credited as co-author. Every TypeScript hook shim and |
…rophe (#4386) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…4386) (#4845) `./setup` on Windows now installs when your home folder has an apostrophe in its name, such as `C:\Users\O'Brien`. Git Bash turns `/c/...` paths into `C:/...` before starting Bun, but skips any path holding an apostrophe, so setup stopped with `Module not found`. Nothing to do: re-run `./setup` after upgrading. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing
|
Follow-up: the rest of this is now fixed on main in #4845. We ran Four smaller spots still pass unconverted paths under such a home folder, and they're out of scope under our minimal Windows support policy: the one-time migration of old |
TypeScript hooks start under a Windows home with an apostrophe, or with MSYS path conversion off
Root cause
Git Bash rewrites a
/c/xargument toC:/xwhen it starts a native program. msys2-runtime skips that rewrite for any argument that contains`'*?[](winsup/cygwin/msys2_path_conv.cc). It skips every argument whenMSYS_NO_PATHCONV=1orMSYS2_ARG_CONV_EXCL=*is set.Each TypeScript hook shim builds
HEREwithpwd, which gives/c/x, and runsbun "$HERE/<hook>.ts". bun.exe cannot open/c/x: it reportsModule not found, andBun.buildthrowsEINVAL: failed to open root directory.gstack-hook-checkhands Bun its entries in the same/c/xspelling.So under a home such as
C:\Users\O'Brien:/autoplanRead barrier returns its "Publication hook unavailable" deny on every Read.gstack-hook-checkreports all 12 registered TypeScript hooks asbun could not bundle the TypeScript entry, so setup's hook-registration gate would refuse them (inferred from that gate's own tests;./setupitself was not run under an apostrophe home).Who is affected
Git Bash or MSYS2 users on Windows are affected in two cases:
',`,[,]or;. I tested each character by passing/c/a<char>b/xto bun.exe. Spaces,( ) & # ! $ % @ { } = + ^ , ~ "and the rest were all rewritten. Windows file names cannot contain*or?.MSYS_NO_PATHCONV=1orMSYS2_ARG_CONV_EXCL=*, which Docker users often set. This breaks every path, apostrophe or not: the unfixed checker failed all 12 hooks on a plainC:\gsp-ctlroot.Cygwin never rewrites arguments, so I expect it to fail on every path. I have not tested it.
Fix
The fix is one mechanism, placed where each path is created:
HEREis set, each shim converts it withcygpath -m:OSTYPE/cygpathtest that already setsGSTACK_BUN_CONFIG. It does nothing off a Windows bash or whencygpathis missing.phase-publication-hookuses the same line with its_AUTOPLAN_HOOK_DIR.bin/gstack-hook-check: passesBUN_ENTRIES=$(cygpath -m $ENTRIES)to Bun under the same test.shellPathalready maps Bun'sC:/xoutput back to the/c/xkeys the checker looks up.The line is written into each shim rather than kept in a shared helper. This follows
GSTACK_BUN_CONFIG, which is also one fixed line per shim, and keeps hook-check self-contained so it can still check an extracted archive. Calling a helper would add aunameplus acygpathprocess to every hook run, and these shims run on every prompt and tool call. The inline line adds a singlecygpath(about 25 ms), and only on Windows.AGENTS.mdstates the rule for new shims.Tests (
test/setup-hook-syntax-gate.test.ts, already in the Windows lane)entries bundle in a root Git Bash does not convert: runs hook-check on a fixture root namedhook root o'brien. On Windows it runs both as-is and withMSYS_NO_PATHCONV=1. On POSIX it runs in a simulated Windows bash:OSTYPE=msys, a fakecygpath, and a fakebunthat rejects the unconverted spelling the way bun.exe does.every shim that runs TypeScript starts its entry …: copies every hook shim that runs a TypeScript entry into that root, 13 today (the registered ones plusmemorable-user-prompt-hook). Each entry is replaced by a stub, and each shim must exit 0 and printentry ran. It uses the same real-or-simulated environment.The space in the fixture root is needed on Windows. It makes Bun quote the path when it starts bash; without quotes, MSYS reads a bare
'in its command line as a quote character (see "Not fixed here").--timeout 120000On Windows the two new tests are the only difference between the runs. The other 3 failures happen with and without the fix: the test harness writes
BUN_CMD='<bun path>'in single quotes, and on the test machine the bun path itself contains an apostrophe. On Linux, the shell-caller ratchet intest/bun-entry-isolation.test.ts(run with-t "shell callers|detector|config-definition") passes 4/4; the whole file gives 7 pass, 3 fail on the partial tree used here, identically with and without the fix, andtest/ceo-mode-handoff-hook.test.ts(which runs the real shim) passes 4/4.Before/after on a real install under a home with an apostrophe (Windows 11, Git Bash)
The test tree is gstack v1.91.101.0 with the upstream 0326b14 hook subsystem copied over it: setup, the 13 shims, the hook-check, and every TypeScript entry with its local imports.
<root>stands for/c/Users/<me>'/…/root.Upstream
bin/gstack-hook-check <root>exits 1:The same bytes reached through a junction with no apostrophe (
C:\gsp-ctl) give 15okand exit 0.With the fix, the checker prints 15
ok, 0fail, and exits 0. It does the same withMSYS_NO_PATHCONV=1and withMSYS2_ARG_CONV_EXCL=*. A TypeScript syntax error planted under that root is still caught:fail plan-ceo-review/bin/mode-handoff-hook <root>/…/mode-handoff-hook.ts:35: Unexpected ;.Each shim was run through
/bin/sh -c '<root>/<shim>'with hook JSON on stdin:After the fix, every row at the apostrophe root matches the same run through the junction.
Off Windows, the line does nothing. With
HERE=/home/o'brien/.claude/skills/gstack/plan-ceo-review/bin,HEREis unchanged underOSTYPE=linux-gnuordarwin23, with or withoutcygpathon PATH, and underOSTYPE=msysorcygwinwith nocygpath. It becomesC:/…only undermsysorcygwinwithcygpathpresent.Not fixed here (found while proving this)
lib/script-invocation.ts(runScriptSync), the MSYS runtime parses bash's Windows command line and treats a bare'as a quote. Node and Bun only add quotes around an argument that has a space or a". SoC:/Users/O'Brien/…/bin/gstack-question-logplus its JSON argument reach bash as a single word, minus the apostrophe, and bash exits 127. With this fix,question-log-hooknow runs, but this spawn still fails.timeline-stop-hook(gstack-slug: exit 127) andmemorable-user-prompt-hook(gstack-config get … failed) fail at their own spawns, which looks like the same bug but I have not traced them.GSTACK_LIB_DIR="$SCRIPT_DIR/../lib" bun -e …,bun "$BIN/…ts", andbun run gen:skill-docs --out-dir "$RENDER_TMP". MSYS leaves environment values with an apostrophe unconverted too. Native Bun then resolves/c/Users/O'Brien/xasC:\c\Users\O'Brien\x. On the test machine, 406 files (skill rendersrender/claude.tmp.<pid>and.brain-sync-status.json) sit inC:\c\Users\<me>'\.gstack, which is where native Bun resolves/c/Users/<me>'/.gstack. They were all written before these test runs.~/.claude/skills/gstack/bin/gstack-decision-log --help, fail withModule not found "/c/Users/…". Running the same bin from its directory (./gstack-decision-log) works.setup's ownbun "$SOURCE_GSTACK_DIR/…"calls pass the same/c/xpaths. I have not runsetupunder such a home.Each of these needs its own change, and items 1 and 3 need changes outside the shims.
Not verified
realpathon their root because macOS/varis/private/var, but they have not run there.