fix(shim): discover install-time shims from disk, not static provider#270
Merged
Conversation
… list Install previously created shim files and shim-map cache entries from the provider's static Shims() declaration, regardless of whether those executables actually existed on disk for the version being installed. On Windows that created phantom python3 and pip shims for python-build- standalone — which ships only python.exe / pythonw.exe in the root and an empty Scripts/ placeholder — leaving users with shims that errored at invocation time with "secondary executable not found." Reshim's scan already handled this correctly by registering only executables it found on disk, so install and reshim disagreed about which shims existed. This change factors the per-version disk scan out of RehashWithCallback into DiscoverShimsForVersion and routes the node, python, and ruby provider createShims() through it. Install now registers exactly the executables that exist in bin/, root/, and Scripts/ — picking up pythonw on Windows, pip / pip3 / pip3.X after ensurepip succeeds, and nothing extra when it fails.
4 tasks
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
Shims()declaration regardless of whether the matching executables existed on disk. On Windows that produced phantompython3andpipshims for python-build-standalone — which ships onlypython.exe/pythonw.exein the root and an emptyScripts/.emptyplaceholder — leaving users with shims that errored at invocation time with "secondary executable not found: pip" even though install reported success.reshimalready handled this correctly by registering only executables it discovered on disk, so install and reshim disagreed about which shims existed. After a fresh install of Python 3.14.2 on Windows, runningdtvem reshimwould drop the phantom entries anddtvem doctorwould flag the cache as out of sync.RehashWithCallbackinto a new exported helper,shim.DiscoverShimsForVersion. Routenode,python, andrubyprovidercreateShims()through it so install registers exactly the executables that exist inbin/, root/, andScripts/. After this change the post-install state matches the post-reshim state by construction.pythonwis now picked up on Windows;pip/pip3/pip3.Xappear whenensurepipsucceeds and are silently omitted when it fails (no more shims promising commands that don't exist).createShimsreturns an explicit error, surfacing what would previously have been a silent "install succeeded but nothing was shimmed" outcome.Resolves #269
What didn't change
Provider.Shims()is still used bymapShimToRuntimeas a fallback when the cache lookup misses (e.g., first invocation ofpipbefore the cache is populated). The static list remains useful as a declaration of expected shims for prefix-matching; it's just no longer the source of truth at install time.installPipIfNeededstill runspython -m ensurepip --default-pip --upgradeand reports "pip configured successfully" / "Failed to configure pip" the same way. The only difference is that on failure, no brokenpip/pip3shims are left behind.Test plan
./rnr check— gofmt clean, golangci-lint reports 0 issues, full test suite passes on Windowsinternal/shim/manager_test.go:bin/contents discovered[python, pythonw]only;.emptyplaceholder ignored[pip, pip3, pip3.14, python, pythonw]root/andScripts/deduped