From bb9226cd98b983bf2d64626cc44529ea2fd62d3b Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 21 Mar 2026 13:26:37 +0100 Subject: [PATCH] fix: ensure PNPM_HOME/bin is in PATH during pnpm setup When upgrading from old pnpm (global bin = PNPM_HOME) to new pnpm (global bin = PNPM_HOME/bin), `pnpm setup` would fail because the spawned `pnpm add -g` checks that the global bin dir is in PATH. Prepend PNPM_HOME/bin to PATH in the spawned process env so the check passes during the transition. Co-Authored-By: Claude Opus 4.6 (1M context) --- engine/pm/commands/package.json | 1 + engine/pm/commands/src/setup/setup.ts | 3 +++ pnpm-lock.yaml | 3 +++ 3 files changed, 7 insertions(+) diff --git a/engine/pm/commands/package.json b/engine/pm/commands/package.json index e4f5036842..b048e37933 100644 --- a/engine/pm/commands/package.json +++ b/engine/pm/commands/package.json @@ -50,6 +50,7 @@ "@pnpm/store.controller": "workspace:*", "@pnpm/types": "workspace:*", "@pnpm/workspace.project-manifest-reader": "workspace:*", + "path-name": "catalog:", "ramda": "catalog:", "render-help": "catalog:", "semver": "catalog:", diff --git a/engine/pm/commands/src/setup/setup.ts b/engine/pm/commands/src/setup/setup.ts index 24ce0b5c30..972dce3bb8 100644 --- a/engine/pm/commands/src/setup/setup.ts +++ b/engine/pm/commands/src/setup/setup.ts @@ -10,6 +10,7 @@ import { type ConfigReport, type PathExtenderReport, } from '@pnpm/os.env.path-extender' +import PATH from 'path-name' import { renderHelp } from 'render-help' export const rcOptionsTypes = (): Record => ({}) @@ -80,11 +81,13 @@ function installCliGlobally (execPath: string, pnpmHomeDir: string): void { }) try { + const binDir = path.join(pnpmHomeDir, 'bin') const { status, error } = spawnSync(execPath, ['add', '-g', `file:${execDir}`], { stdio: 'inherit', env: { ...process.env, PNPM_HOME: pnpmHomeDir, + [PATH]: `${binDir}${path.delimiter}${process.env[PATH] ?? ''}`, }, }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 781bea09b5..3fa8094ee3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3524,6 +3524,9 @@ importers: '@pnpm/workspace.project-manifest-reader': specifier: workspace:* version: link:../../../workspace/project-manifest-reader + path-name: + specifier: 'catalog:' + version: 1.0.0 ramda: specifier: 'catalog:' version: '@pnpm/ramda@0.28.1'