fix: resolve symlinks in pnpm/bun global install detection (#24744)

Use tryRealpath() instead of path.resolve() when comparing expected
package paths in detectGlobalInstallManagerForRoot(). path.resolve()
only normalizes path strings without following symlinks, causing pnpm
global installs to go undetected since pnpm symlinks node_modules
entries into its .pnpm content-addressable store.

Fixes #22768

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Glucksberg
2026-02-23 23:33:24 -04:00
committed by GitHub
parent 1e23d2ecea
commit a3b82a563d

View File

@@ -84,7 +84,8 @@ export async function detectGlobalInstallManagerForRoot(
const globalReal = await tryRealpath(globalRoot);
for (const name of ALL_PACKAGE_NAMES) {
const expected = path.join(globalReal, name);
if (path.resolve(expected) === path.resolve(pkgReal)) {
const expectedReal = await tryRealpath(expected);
if (path.resolve(expectedReal) === path.resolve(pkgReal)) {
return manager;
}
}
@@ -94,7 +95,8 @@ export async function detectGlobalInstallManagerForRoot(
const bunGlobalReal = await tryRealpath(bunGlobalRoot);
for (const name of ALL_PACKAGE_NAMES) {
const bunExpected = path.join(bunGlobalReal, name);
if (path.resolve(bunExpected) === path.resolve(pkgReal)) {
const bunExpectedReal = await tryRealpath(bunExpected);
if (path.resolve(bunExpectedReal) === path.resolve(pkgReal)) {
return "bun";
}
}