Skip to content

Fix hook.sh routing to Windows binary under native WSL2 - #67

Open
ram510 wants to merge 1 commit into
semgrep:mainfrom
ram510:fix/wsl2-hook-platform-detection
Open

Fix hook.sh routing to Windows binary under native WSL2#67
ram510 wants to merge 1 commit into
semgrep:mainfrom
ram510:fix/wsl2-hook-platform-detection

Conversation

@ram510

@ram510 ram510 commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • plugin/scripts/hook.sh routed every invocation to hook-windows-amd64.exe whenever WSL_DISTRO_NAME was 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.
  • In that (very common) case, the Windows binary can't lock/access its settings from the Linux side, producing Could not lock settings, can't login on essentially every PreToolUse/PostToolUse/SessionStart hook call.
  • Removes the special-cased WSL_DISTRO_NAME branch entirely and lets the existing $OSTYPE case handle it — $OSTYPE already resolves to linux-gnu under WSL2, so the correct hook-linux-{amd64,arm64} binary gets picked automatically.

Fixes #66

Test plan

  • Reproduced the bug on WSL2 (Ubuntu 26.04, WSL_DISTRO_NAME=Ubuntu, OSTYPE=linux-gnu, HOSTTYPE=x86_64): before this change, hook.sh execs hook-windows-amd64.exe; after this change, it execs hook-linux-amd64.
  • Would appreciate a maintainer confirming there isn't a legitimate scenario this WSL branch was meant to cover (e.g. a Windows-native Claude Code build shelling out via wsl.exe) that this removal regresses — I couldn't find one, since such a process would also present as OSTYPE=linux-gnu inside the WSL shell and still need the Linux binary to execute correctly there.

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
@CLAassistant

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

hook.sh execs the Windows binary under WSL2, breaking login/settings lock (Could not lock settings, can't login)

2 participants