fix(statusline): auto-detect jq on Windows (WinGet/scoop paths)#3
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2
On Windows (Git Bash),
jqinstalled 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.mjsstatusline.shthat:jqis already on PATH (no-op if found)/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/shimsjq/jq.exetoPATHskills/webup-statusline/SKILL.md+ READMEs (en, zh, ja)Closes #2