fix(coding-agent): fix pnpm self-update bin-dir

closes #5689
This commit is contained in:
Armin Ronacher
2026-06-14 01:31:32 +02:00
parent 5be8c31fa7
commit 2fbdff9dab
2 changed files with 14 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
### Fixed
- Fixed `pi update` for pnpm global installs whose configured `global-bin-dir` no longer matches the active pnpm home ([#5689](https://github.com/earendil-works/pi/issues/5689)).
- Fixed inherited OpenCode/OpenCode Go completion model metadata to omit long-retention cache fields for routes that reject `prompt_cache_retention` ([#5702](https://github.com/earendil-works/pi/issues/5702)).
- Fixed custom provider config so plain uppercase API key and header values remain literals instead of being treated as legacy environment references; use explicit `$ENV_VAR` syntax for environment variables ([#5661](https://github.com/earendil-works/pi/issues/5661)).

View File

@@ -109,19 +109,27 @@ function getSelfUpdateCommandForMethod(
switch (method) {
case "bun-binary":
return undefined;
case "pnpm":
case "pnpm": {
const match = readCommandOutput("pnpm", ["root", "-g"])
? undefined
: /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(getPackageDir());
const binDirArgs = match
? [`--config.global-bin-dir=${process.env.PNPM_HOME || dirname(dirname(match[1]))}`]
: [];
return makeSelfUpdateCommand(
makeSelfUpdateCommandStep("pnpm", [
"install",
"-g",
"--ignore-scripts",
"--config.minimumReleaseAge=0",
...binDirArgs,
updatePackageName,
]),
updatePackageName === installedPackageName
? undefined
: makeSelfUpdateCommandStep("pnpm", ["remove", "-g", installedPackageName]),
: makeSelfUpdateCommandStep("pnpm", ["remove", "-g", ...binDirArgs, installedPackageName]),
);
}
case "yarn":
return makeSelfUpdateCommand(
makeSelfUpdateCommandStep("yarn", ["global", "add", "--ignore-scripts", updatePackageName]),
@@ -205,7 +213,9 @@ function getGlobalPackageRoots(method: InstallMethod, _packageName: string, npmC
}
case "pnpm": {
const root = readCommandOutput("pnpm", ["root", "-g"]);
return root ? [root, dirname(root)] : [];
if (root) return [root, dirname(root)];
const match = /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(getPackageDir());
return match ? [match[1]] : [];
}
case "yarn": {
const dir = readCommandOutput("yarn", ["global", "dir"]);