You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows (Git Bash): the hook rewrites grep over a large glob into rtk.exe, which fails with "Argument list too long" and the command never runs #4210
Thanks for rtk. We hit this on Windows and it seemed worth writing up because the agent's command does not run at all, which CONTRIBUTING's "Never Block" is meant to rule out.
Summary
Under Git Bash, the hook rewrites grep … <glob> into rtk grep … <glob>. The shell expands the glob into the argument list in both cases, but rtk.exe is a native Windows program, so the expanded command line has to fit Windows' 32,767-character limit. The MSYS grep it replaces has no such limit. A grep that works starts failing once the hook rewrites it:
/usr/bin/bash: line 1: /c/Users/<user>/.local/bin/rtk: Argument list too long
(exit code 126). Because the failure happens when bash execs rtk.exe, rtk never starts, so a fallback inside rtk cannot catch it; the decision has to be made at rewrite time.
Reproduction (rtk 0.49.0, Windows 11, Git Bash)
mkdir -p /tmp/rtk-e2big &&cd /tmp/rtk-e2big
foriin$(seq -w 1 600);doecho"line $i">"some-reasonably-long-file-name-for-the-glob-test-$i.txt";doneecho /tmp/rtk-e2big/*.txt | wc -c # 43200 here
rtk rewrite 'grep -li zzz /tmp/rtk-e2big/*.txt'# rtk grep -li zzz /tmp/rtk-e2big/*.txt (exit 3)
/usr/bin/grep -li zzz /tmp/rtk-e2big/*.txt;echo"rc=$?"# rc=1: no match, ran normally
rtk grep -li zzz /tmp/rtk-e2big/*.txt;echo"rc=$?"# Argument list too long, rc=126
Typed as a plain grep -li zzz /tmp/rtk-e2big/*.txt in a Claude Code Bash call with rtk hook claude installed, the hook rewrites it and the call fails with the same error. With 60 files (about 10,900 characters) the rewritten command runs fine, so this only bites past the Windows limit.
Expected
The command runs, either rewritten or left as it was.
Suggested fix
The hook cannot know the expanded length, because the shell expands the glob after the rewrite. One option is to leave a segment un-rewritten on Windows when it contains an unquoted glob character (*, ?, [), perhaps only when the hook runs under an MSYS or Cygwin shell. The exclude_commands workaround works but costs the rewrite for every grep.
We only tested Git Bash; PowerShell and cmd may behave differently. Happy to test a fix on Windows.
I looked at a fix for this and stopped before writing code, because every option I can see changes how much the hook rewrites on Windows, which is your call. Notes at develop 32b2ec43:
The rewrite path (rewrite_single, src/discover/registry.rs:823; rewrite_compound, :1253) has no check for command length, glob characters or the shell it runs under, and src/ has no handling for the 32,767-character cap. So there is no existing guard to extend.
The failure happens when Git Bash execs rtk.exe with the already-expanded argument list, before rtk starts, so nothing inside rtk can catch it. The hook only sees the typed command, not the expanded length.
Do not rewrite a command with an unquoted *, ? or [ on Windows (or only when MSYSTEM says Git Bash/MSYS). Fixes the reported case, but gives up the rewrite for most glob grep/ls/find there, where nearly all globs expand to a few hundred characters and work today.
Skip the rewrite when the typed command is already near the cap (for example over 30,000 characters). Small and safe, but it does not cover this report, where the typed command is short and the expansion is what overflows.
Keep the current behaviour and document exclude_commands = ["grep"] as the workaround.
For weighing it: in my own history (about 7,000 hook-rewritten greps over two months on Windows) no glob came close to the cap, so this is rare, it fails loudly (rc 126 with a clear message) and loses no data. Against that, CONTRIBUTING.md:56 and docs/guide/getting-started/supported-agents.md:341 say hooks never stop a command from running. Happy to send a PR for whichever you prefer.
Produced with AI assistance (Claude Code) operated by me (HetCreep); the code was read at 32b2ec43, nothing was rerun for this comment.
Activity
HetCreep commentedon Oct 23, 2026
I looked at a fix for this and stopped before writing code, because every option I can see changes how much the hook rewrites on Windows, which is your call. Notes at develop
32b2ec43:rewrite_single,src/discover/registry.rs:823;rewrite_compound,:1253) has no check for command length, glob characters or the shell it runs under, andsrc/has no handling for the 32,767-character cap. So there is no existing guard to extend.rtk.exewith the already-expanded argument list, before rtk starts, so nothing inside rtk can catch it. The hook only sees the typed command, not the expanded length.Options:
*,?or[on Windows (or only whenMSYSTEMsays Git Bash/MSYS). Fixes the reported case, but gives up the rewrite for most globgrep/ls/findthere, where nearly all globs expand to a few hundred characters and work today.exclude_commands = ["grep"]as the workaround.For weighing it: in my own history (about 7,000 hook-rewritten greps over two months on Windows) no glob came close to the cap, so this is rare, it fails loudly (rc 126 with a clear message) and loses no data. Against that,
CONTRIBUTING.md:56anddocs/guide/getting-started/supported-agents.md:341say hooks never stop a command from running. Happy to send a PR for whichever you prefer.Produced with AI assistance (Claude Code) operated by me (HetCreep); the code was read at
32b2ec43, nothing was rerun for this comment.