Fix pnpm prerelease selection (#774) and preinstall shim deadlock#798
Closed
AMDphreak wants to merge 1 commit intonodejs:mainfrom
Closed
Fix pnpm prerelease selection (#774) and preinstall shim deadlock#798AMDphreak wants to merge 1 commit intonodejs:mainfrom
AMDphreak wants to merge 1 commit intonodejs:mainfrom
Conversation
1. Update resolveDescriptor to prefer stable matching versions unless the range explicitly targets prereleases. 2. Introduce COREPACK_PACKAGE_MANAGER_LOCATOR environment variable to ensure sub-invocations during install phases use the same binary version, bypassing shim race conditions. 3. Fix Descriptor vs Locator type error in executePackageManagerRequest. 4. Add isPrereleaseRange helper in semverUtils.
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.
This PR addresses two related issues encountered on Windows with Corepack...\n\n### Issue 1: Deadlock during corepack use with preinstall scripts\nWhen a project has a preinstall script (e.g. pnpm dlx only-allow pnpm), corepack use pnpm@latest can crash during the install phase. The child shell trying to run pnpm from the PATH cannot find it because the shim is being re-linked or locked by the main corepack process. This aborts the installation and can leave shims broken.\n\n### Issue 2: Incorrect Prerelease Selection (#774)\nRunning corepack use pnpm without a version often resolves to the newest prerelease (e.g. 11.0.0-dev.1005) instead of the latest stable (e.g. 10.4.1) because * matches prereleases in satisfiesWithPrereleases and semver comparison makes the prerelease 'higher' than the previous stable. This is especially problematic when the prerelease changes internal binary paths (e.g. from .cjs to .mjs), causing shims to break with MODULE_NOT_FOUND.\n\n### Changes\n1. Update
esolveDescriptor in Engine.ts to prefer stable versions if the requested range does not explicitly have a prerelease tag.\n2. Add isPrereleaseRange helper in semverUtils.ts to detect ranges targeting prereleases.\n3. In
unVersion (and �xecutePackageManagerRequest), use COREPACK_PACKAGE_MANAGER_LOCATOR environment variable to ensure sub-invocations use the same binary version, bypassing PATH/shim race conditions.