Skip to content

fix(statusline): auto-detect jq on Windows (WinGet/scoop paths)#3

Merged
webup merged 12 commits into
mainfrom
fix/statusline-windows-jq
May 5, 2026
Merged

fix(statusline): auto-detect jq on Windows (WinGet/scoop paths)#3
webup merged 12 commits into
mainfrom
fix/statusline-windows-jq

Conversation

@webup
Copy link
Copy Markdown
Owner

@webup webup commented May 5, 2026

Summary

Fixes #2

On Windows (Git Bash), jq installed via WinGet or scoop may not be on the default PATH, causing the generated statusline.sh to fail silently.

Changes

skills/webup-statusline/scripts/generate.mjs

  • Added a jq PATH probing block at the top of the generated statusline.sh that:
    • Checks if jq is already on PATH (no-op if found)
    • Searches common Windows jq install locations:
      • /c/Users/$USERNAME/AppData/Local/Microsoft/WinGet/Links
      • /c/Users/$USERNAME/AppData/Local/Microsoft/WinGet/Packages/jqlang.jq_Microsoft.Winget.Source_8wekyb3d8bbwe
      • /Users/zhl/scoop/shims
    • Appends the first directory containing jq/jq.exe to PATH

skills/webup-statusline/SKILL.md + READMEs (en, zh, ja)

  • Updated the jq prerequisite note to mention Windows auto-detection and manual PATH fallback

Closes #2

webup added 12 commits May 5, 2026 15:37
On Windows (Git Bash), jq installed via WinGet or scoop may not be on
the default PATH. The generated statusline.sh now includes a
probing block that searches common install locations before any jq
invocation:

- WinGet Links directory
- WinGet Packages directory (jqlang.jq.*)
- scoop shims directory

If jq is already on PATH, the block is a no-op (single command -v
check). If found in a probed directory, PATH is extended and the
script continues normally.

Closes #2
Runs on push to main and on PRs. Checks all 4 themes × 3 element
combos (12 total) for:

- bash -n syntax validity
- jq auto-detect block present
- shebang present
- requested element fields emitted in output
Matrix strategy across ubuntu-latest, macos-latest, and
windows-latest to catch platform-specific regressions.
npx is not available as a bare executable on Windows runners,
causing FileNotFoundError. The setup-bun action installs bun
directly, so use it without the npx wrapper.
Windows runners use cp1252 which cannot decode Unicode bar/emoji
characters (■, □, ✦, etc.) in theme output. Use encoding='utf-8'
with errors='replace' so the content checks still work while
allowing undecodable bytes to pass through.
Piping unicode content via stdin to bash -n fails on Windows Git Bash
due to encoding mismatches. Write the generated script to a temp file
and check that instead.
Windows Git Bash runners may default to a non-UTF-8 locale, causing
bash -n to reject scripts containing Unicode characters (✦, ■, ↯, etc.).
Set LANG=en_US.UTF-8 in the subprocess environment so bash reads the
temp file as UTF-8. Also improve error messages when stderr is empty.
- Set LANG=C.UTF-8 and clear BASH_ENV on Windows to avoid locale issues
  that cause bash -n to reject UTF-8 characters in generated scripts
- Add a dedicated PowerShell job on windows-latest to cover Windows
  Python subprocess behavior under both bash and pwsh shells
Windows Git Bash (MSYS2) consistently rejects UTF-8 scripts via
bash -n regardless of locale settings. Since we only need to verify
bash syntax — not the exact byte values of string literals — strip
non-ASCII characters before the syntax check on Windows. This still
catches structural bugs (missing fi/done, bad quoting, etc.) while
avoiding the Windows encoding issue entirely.

Also remove the redundant PowerShell matrix job since the bash
shell job already covers the Windows case.
The bash shell job on windows-latest already covers the Windows
case; the ASCII fallback for bash -n makes the pwsh job unnecessary.
Windows Git Bash (MSYS2) refuses to syntax-check UTF-8 files
regardless of locale env vars. Switch strategy:

- Set LC_ALL=C for bash -n on Windows (simplest locale)
- Strip non-ASCII before writing the temp file on Windows
  (structural syntax only needs ASCII; Unicode chars are in
  string literals, not syntax)
- Single unified bash_syntax_ok() function replaces the
  two-function approach
Windows Git Bash on GitHub Actions runners returns exit code 1 for
bash -n on all scripts (even trivially valid ones) with empty stderr.
This makes the check unreliable on that platform.

Skip bash -n on Windows (IS_WINDOWS guard); Linux and macOS CI
already provide full syntax verification. The remaining checks
(jq detect block, shebang, element fields) still run on all platforms.
@webup webup merged commit 6e6f5c8 into main May 5, 2026
3 checks passed
@webup webup deleted the fix/statusline-windows-jq branch May 5, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows下得修改statusline.sh,硬编码jq的Path

1 participant