fix(coding-agent): keep bun/npm routing for regular-file entries on Windows

Bun's global bin entry on Windows is a regular-file .exe shim, not a
symlink, so the standalone-binary override would have rerouted a
legitimate bun-managed install to in-place binary replacement and
clobbered the shim. Gate the override on POSIX, where package-manager
bin entries are always symlinks; add a regression test.
This commit is contained in:
can1357
2026-07-26 15:11:25 +02:00
parent e0c26cc262
commit 97ea63920b
2 changed files with 27 additions and 3 deletions
+7 -3
View File
@@ -239,12 +239,16 @@ function resolveUpdateMethod(
if (miseDataDir && isPathInDirectory(ompPath, path.join(miseDataDir, "shims"))) return "mise";
// A plain executable file in a package-manager bin dir is the standalone
// binary the installer placed there, not an npm/bun-managed install (those
// symlink into node_modules). When the global bin dir overlaps the
// symlink into node_modules on POSIX). When the global bin dir overlaps the
// installer's default (~/.local/bin), classifying by directory alone routes
// a binary install through npm/bun, whose reinstall then collides with the
// existing file (npm EEXIST). Fall through to binary replacement instead.
if (bunBinDir && isPathInDirectory(ompPath, bunBinDir) && !ompIsRegularFile) return "bun";
if ((npmBinDir && isPathInDirectory(ompPath, npmBinDir) && !ompIsRegularFile) || isWindowsScriptLauncher)
// Windows is excluded: there package managers write regular-file shims
// (bun's .exe launcher, npm's .cmd/.ps1), so a regular file is NOT evidence
// of a standalone install and the override would hijack managed installs.
const isStandaloneRegularFile = ompIsRegularFile && process.platform !== "win32";
if (bunBinDir && isPathInDirectory(ompPath, bunBinDir) && !isStandaloneRegularFile) return "bun";
if ((npmBinDir && isPathInDirectory(ompPath, npmBinDir) && !isStandaloneRegularFile) || isWindowsScriptLauncher)
return "npm";
return "binary";
}