Conversation
which/existsSync resolve the grok binary path without the .exe suffix on Windows, and existsSync() resolves it leniently even though the real file is grok.exe. spawn() doesn't share that leniency, so every task failed with ENOENT unless GROK_BIN was set to the exact .exe path manually. resolveSpawnable() checks for .exe/.cmd/.bat on win32 before falling back to the bare path, applied to the GROK_BIN, which, and fallback resolution paths. Fixes zachdunn#2
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.
Fixes #2
Problem
On Windows (Git Bash / MSYS2),
grok-companion.mjsfails every task with:resolveGrokBin()resolves the binary path viawhich grok(or the~/.grok/bin/grokfallback) and validates it withexistsSync(). The actual installed binary isgrok.exe, but:which grok(Git Bash) returns the path without the.exesuffixexistsSync()on Windows resolves that bare path leniently and returnstrueeven though the file on disk isgrok.exespawn()does not share that leniency and requires the exact filename, so it throwsENOENTSetting
GROK_BINmanually didn't help either, since the same lenientexistsSync()check was used for that path too. Thesetupsubcommand also silently masked this: it reportedok: truewith a resolvedbinarypath, whilegrokVersion()(which spawns that same unresolved path) quietly returnednull.Fix
Added
resolveSpawnable(), which onwin32checks for a.exe/.cmd/.batsuffix when the bare path doesn't spawn cleanly, and applied it to all three resolution sources (GROK_BIN,which, and the default fallback path).Verification
Tested on Windows with
GROK_BINunset:Before:
{ "ok": true, "binary": "...\grok", "version": null }taskrun →Failed to launch grok: spawn ...\grok ENOENTAfter:
{ "ok": true, "binary": "...\grok.exe", "version": "grok 0.2.118 (1e1687c1cf) [stable]" }task --read "..."→ runs end-to-end successfully.No changes to non-Windows behavior —
resolveSpawnable()is a no-op passthrough (justexistsSync) on other platforms.