Fix hook.sh routing to Windows binary under native WSL2 - #67
Open
ram510 wants to merge 1 commit into
Open
Conversation
WSL_DISTRO_NAME is set for any process running inside a WSL
distro, including a genuinely native Linux install of Claude Code
(claude is the Linux ELF binary, not a Windows process reached via
interop). The unconditional WSL_DISTRO_NAME check made hook.sh
always exec hook-windows-amd64.exe in that common case, which then
fails to lock/access its settings from within the Linux environment
("Could not lock settings, can't login") on every PreToolUse/
PostToolUse/SessionStart hook invocation.
$OSTYPE already resolves correctly to "linux-gnu" in this
environment, so the existing linux* case picks the right
hook-linux-{amd64,arm64} binary once the special-cased WSL branch
is removed.
Fixes semgrep#66
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
plugin/scripts/hook.shrouted every invocation tohook-windows-amd64.exewheneverWSL_DISTRO_NAMEwas set, but that env var is present for any process inside a WSL distro — including a genuinely native Linux install of Claude Code, not just Windows processes reaching in via WSL interop.Could not lock settings, can't loginon essentially everyPreToolUse/PostToolUse/SessionStarthook call.WSL_DISTRO_NAMEbranch entirely and lets the existing$OSTYPEcase handle it —$OSTYPEalready resolves tolinux-gnuunder WSL2, so the correcthook-linux-{amd64,arm64}binary gets picked automatically.Fixes #66
Test plan
WSL_DISTRO_NAME=Ubuntu,OSTYPE=linux-gnu,HOSTTYPE=x86_64): before this change,hook.shexecshook-windows-amd64.exe; after this change, it execshook-linux-amd64.wsl.exe) that this removal regresses — I couldn't find one, since such a process would also present asOSTYPE=linux-gnuinside the WSL shell and still need the Linux binary to execute correctly there.