pnpm update --global --latest does not work properly
vemoo opened this issue · comments
pnpm version: 6.14.3
Code to reproduce the issue:
Running inside docker run --interactive --rm --tty node:14 /bin/bash
> npm install --global pnpm
> pnpm install --global typescript@4.3
> tsc --version
Version 4.3.5
> pnpm update --global --latest
Already up-to-date # error, should have installed 4.4.2
> pnpm update --global --interactive --latest
? Choose which packages to update (Press <space> to select, <a> to toggle all, <i> to invert selection) …
❯ ● typescript 4.3.5 ❯ 4.4.2
Enter to start updating. Ctrl-c to cancel.
# Select it and press enter
Already up-to-date
> tsc --version
Version 4.3.5
# error, did not install
Expected behavior:
Global packages get updated to latest version.
Actual behavior:
Global packages are not updated.
Additional information:
node -v
prints: v14.17.4- Windows, macOS, or Linux?: Linux (node:14 image), not tested on other OS
Same here:
node: v14.17.5
pnpm: v6.14.3
System:
Host: ZenBook Kernel: 5.4.0-81-generic x86_64 bits: 64
Desktop: KDE Plasma 5.18.5 Distro: Ubuntu 20.04.3 LTS (Focal Fossa)
I've been investigating this and I've found the following:
For the global case I prepare by running:
pnpm add --global cross-env@6
, then I run pnpm update --global --latest
and here:
pnpm/packages/core/src/install/index.ts
Lines 463 to 471 in 3b4dc17
opts.ignoreCurrentPrefs
is true
, which causes parseWantedDependencies
to return an empty array and the package doesn't get updated.
But if do the equivalent in a project: pnpm add cross-env@6
and then pnpm update --latest
, opts.ignoreCurrentPrefs
is false
, and parseWantedDependencies
returns
[
{
alias: 'cross-env',
dev: false,
optional: false,
pinnedVersion: undefined,
raw: 'cross-env@latest',
pref: 'latest'
}
]
But what I don't know is whether the issue is that opts.ignoreCurrentPrefs
shouldn't be true
or maybe is the line 464 that's wrong.