Skip to content

gstack-learnings-log silently fails on Windows (git-bash) — all AI-logged learnings dropped #1950

Closed

Description

@okyhm520

Summary

On Windows running gstack under git-bash, bin/gstack-learnings-log always exits 1 without writing anything, AND without surfacing any error to the caller. The bin swallows stderr with 2>/dev/null, so neither the user nor the AI agent sees that the call failed.

Root cause: the bin computes SCRIPT_DIR via pwd, which returns a POSIX path (/c/Users/...) under git-bash. The bin then interpolates that into a bun import statement (import { hasInjection } from '$SCRIPT_DIR/../lib/jsonl-store.ts'). Bun on Windows can't resolve POSIX-style paths as ES module specifiers and throws Cannot find module, which gets swallowed.

Impact: every Windows user has /learn, /review, /ship, /investigate, etc. silently losing every AI-captured learning. The feature is structurally non-functional on Windows.

gstack-decision-log does not appear to share this code path, so cross-session decision memory still works.

Environment

gstack 1.57.7.0 (just upgraded from 1.56.0.0)
OS Windows 11 Pro 26200
Shell MINGW64_NT bash (git-for-windows 2.54.0)
bun 1.3.14 (Windows x64)
Claude Code (host)

Repro

From git-bash, with gstack installed at ~/.claude/skills/gstack:

~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"learn","type":"pitfall","key":"test-key","insight":"hello world","confidence":5,"source":"observed"}'
echo "exit=$?"
wc -l ~/.gstack/projects/$(~/.claude/skills/gstack/bin/gstack-slug | sed 's/SLUG=//;s/ .*//')/learnings.jsonl

Expected: exit=0, line count increases by 1.

Actual: exit=1, line count unchanged. No stderr output.

Root cause (verified)

Running the validation pipeline manually with stderr unsuppressed reveals:

error: Cannot find module '/c/Users/okyhm/.claude/skills/gstack/bin/../lib/jsonl-store.ts'
       from 'C:\Users\okyhm\[eval]'

Bun v1.3.14 (Windows x64)

Bun is started with cwd C:\Users\okyhm (Windows form) but the import statement uses /c/Users/... (POSIX form). Bun's module resolver on Windows treats /c/... as an absolute filesystem path that doesn't exist — there's no C: drive letter prefix, just a leaf c under root.

The relevant lines in bin/gstack-learnings-log:

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"          # returns /c/Users/... on git-bash
...
VALIDATED=$(printf '%s' "$INPUT" | bun -e "
import { hasInjection } from '$SCRIPT_DIR/../lib/jsonl-store.ts';
...
" 2>/dev/null)                                       # ← stderr swallowed, error invisible

if [ $? -ne 0 ] || [ -z "$VALIDATED" ]; then
  exit 1                                             # ← silent failure
fi

Suggested fix

One-line conversion via cygpath (available in every git-for-windows install):

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if command -v cygpath >/dev/null 2>&1; then
  SCRIPT_DIR=$(cygpath -m "$SCRIPT_DIR")   # /c/Users/... → C:/Users/...
fi

cygpath -m (mixed mode) produces Windows-style paths with forward slashes, which bun accepts as both filesystem paths and import specifiers. No-op on non-Windows (cygpath is absent).

I've verified this works locally:

$ ~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"learn","type":"pitfall","key":"test","insight":"works","confidence":9,"source":"observed"}'
$ echo $?
0
# learning appended successfully

Secondary concern: silent stderr

Independent of the path fix, the 2>/dev/null on the bun subshell is a footgun. Any future validation failure (invalid JSON, bad type, injection rejected, etc.) is invisible to the caller. The bin's own error messages are already prefixed (gstack-learnings-log: ...) so they're safe to surface. Consider dropping the redirect, or at least logging to a debug file.

This is the reason this bug went undetected — every Windows user since the bin was introduced has been silently losing learnings, and neither the user nor the AI got any signal that something was wrong.

Test coverage suggestion

A minimal regression test:

# On any platform — exits 0 on success, 1 on validation failure (visible reason)
output=$(./bin/gstack-learnings-log '{"skill":"test","type":"pitfall","key":"a","insight":"b","confidence":1,"source":"observed"}' 2>&1)
[ $? -eq 0 ] || { echo "BUG: bin failed: $output"; exit 1; }

The current Linux CI passes because POSIX /home/runner/... paths resolve fine in bun — only the Windows-specific path-format mismatch triggers the failure. If the Windows-tests workflow runs the bin at all, it would have caught this.

Activity

  1. ramgalv commented on Jun 10, 2026

    @ramgalv

    Confirming independently — still reproduces on v1.57.9.0 (bun 1.3.13, Windows 11 26200, git-bash). Same root cause: the /c/Users/... MSYS path passed into the bun -e import doesn't resolve.

    Two things toward a fix:

    1. Tested: convert the lib path to Windows form before the import. cygpath ships with git-bash and resolves correctly:

      LIB="$SCRIPT_DIR/../lib/jsonl-store.ts"
      command -v cygpath >/dev/null 2>&1 && LIB="$(cygpath -w "$LIB")"
      # then interpolate "$LIB" (or a file:// URL) into the bun import

      On my box cygpath -w yields C:\Users\<user>\.claude\skills\gstack\lib\jsonl-store.ts, which Bun resolves. A file:// URL works too. The same treatment is needed anywhere a $SCRIPT_DIR-derived path is fed to a bun -e import.

    2. Stop swallowing the error: the 2>/dev/null on the validation bun -e is what makes this silent. Surfacing that stderr (or checking the import once at startup) turns "learnings vanish" into a visible error.

    Scope on my install: of the bin/ scripts using bun -e, only gstack-learnings-log interpolates a $SCRIPT_DIR/../lib/*.ts import this way, so the user-facing impact is the learnings pipeline specifically.

  2. added a commit that references this issue on Jul 1, 2026
  3. time-attack commented on Jul 15, 2026

    @time-attack
    Contributor

    @16francej Please close this issue as resolved. #2077 fixed the Git Bash path handling for the learnings logger and now surfaces Bun validation errors, so Windows failures are no longer silently discarded.

  4. garrytan commented on Aug 7, 2026

    @garrytan
    Owner

    Verified already fixed on main. bin/gstack-learnings-log:10-15 converts the MSYS-style path with cygpath -m before the bun -e import (MINGW/MSYS/CYGWIN detection), and validation errors now surface on stderr instead of a silent exit 1 (lines 22-26 + 81-86).

    Regression test: test/bin-windows-bun-import-paths.test.ts ("bin/ — Windows bun-import path guard (#1950)").

    Run /gstack-upgrade if your install predates the fix. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions