fix: point pn to pnpm binary directly, not to @pnpm/exe/pn

pnpm self-update only replaces the pnpm binary — it does not update
other files in the @pnpm/exe package (setup.js, pn, pnpx, pnx all
remain from the v10 bootstrap). So @pnpm/exe/pn may not exist at all.

Instead of relying on @pnpm/exe/pn, create the aliases directly:
- pn → symlink to the pnpm binary
- pnpx/pnx → shell scripts that exec "pnpm dlx"

Also remove the setup.js call after self-update since it's no longer
needed and would run the v10 version which doesn't know about pn.
This commit is contained in:
Zoltan Kochan
2026-03-26 18:58:55 +01:00
parent b179ac1ba6
commit 188c8307ce
4 changed files with 243 additions and 240 deletions

View File

@@ -59,17 +59,6 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
if (exitCode !== 0) {
return exitCode
}
// self-update replaces package files but does not re-run preinstall
// scripts, so setup.js (which hardlinks pn/pnpx/pnx to the binary)
// needs to be run explicitly.
if (standalone) {
const exeDir = path.join(dest, 'node_modules', '@pnpm', 'exe')
const setupScript = path.join(exeDir, 'setup.js')
if (existsSync(setupScript)) {
await runCommand(process.execPath, [setupScript], { cwd: exeDir })
}
}
}
// Create pn/pnx alias bin links if the installed version supports them