Conversation
On Windows, %LocalAppData%\Microsoft\WindowsApps\store.exe (the Microsoft Store CLI shim) sits ahead of ~\go\bin on PATH and wins command resolution. After go install, typing `store apply` runs the shim instead of this tool. The reporter's own workaround was a PowerShell $PROFILE function that bypasses PATH lookup. This adds two layers of guidance: 1. A README install note documents the shim collision and the PowerShell wrapper so anyone reading the install docs sees the fix. 2. checkWindowsShimCollision runs at startup and, when it detects the shim ahead of this binary on PATH, prints the same hint to stderr once. A marker under the user's config dir suppresses future prints. No-op on non-Windows. The pure parser (shimShadowsBinary) is split out and tested across shim-first, our-binary-first, blank-input, third-party-store.exe, and case-insensitive cases. Closes #60.
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.
What this does
On Windows,
%LocalAppData%\Microsoft\WindowsApps\store.exe(the Microsoft Store CLI shim) sits ahead of~\go\binon PATH and wins command resolution. Aftergo install, typingstore applyruns the Microsoft shim instead of this tool, and the user gets no signal that anything is wrong. @OliStarCooke reported this in #60 and shared a PowerShell$PROFILEwrapper that bypasses PATH lookup. This PR makes that fix discoverable.I considered renaming the binary, shipping a Windows-only
dotstorealias, publishing to Scoop, and a few other options. The reporter himself said "more of a heads up kind of thing," and a Scoop or rename is a much heavier intervention for what is, today, a small Windows user base. So this PR keeps the binary name and adds two guidance layers.How it works
Layer 1: README. A new Installation subsection documents the collision, shows
where.exe storeso the reader can confirm the shim is winning, and gives the PowerShell$PROFILEsnippet:It also explains why the function is enough (PowerShell function dispatch beats PATH lookup, so the shim never wins for typed
storeinvocations).Layer 2: runtime hint.
checkWindowsShimCollisionruns at the top ofmain(). On Windows only, it shells out towhere.exe store, parses the result, and if the first match is aWindowsAppspath that is not this binary, prints the same hint to stderr. A marker file at%AppData%\store\windows-shim-hint-shownsuppresses subsequent prints; deleting it brings the hint back. No-op on Linux and macOS, gated entirely byruntime.GOOS == "windows"so the cost on other platforms is one branch.The case where this layer actually helps is when a user invokes the binary by full path (
~\go\bin\store.exe apply) after the shim has confused them — they get the wrapper snippet right where they're working.Tests
shimShadowsBinaryis the pure parser, split out so it stays testable on every platform. Nine cases cover shim-first, our-binary-first, only-shim, only-our-binary, empty input, case-insensitive matching on both the exe path and the WindowsApps segment, third-partystore.exeoutside WindowsApps (does not trigger), and leading blank lines. The orchestration around it (filesystem marker,where.exe,os.Executable) only runs on Windows so I haven't covered those paths from a Linux runner; the marker logic is small and the rest is stdlib.Caveats
store applyand PATH resolves to the shim, the shim runs and our code never sees the invocation. The README is the catch for that case.store doctorcheck for the same condition, since the reporter's own assessment was that this is a heads-up rather than a recurring health concern. Easy to add later if the issue resurfaces.Test plan
go build ./... && go vet ./... && go test ./...clean on Linux