#9094·pnpm

Self Updating on Windows

Author: WhosLoganCreated Feb 12, 2025Updated Sep 26, 2026
Labelstype: featurepriority: 2

Contribution

Describe the user story

Unlike Unix based systems, on Windows you are not able to delete a file that currently has an open handle to it. This causes pnpm update to fail with the (probably) well known message  EPERM  EPERM: operation not permitted, unlink 'C:\Users\\\user\AppData\Local\pnpm\pnpm.EXE'.

This causes the auto updater to fail entirely and forces alternate methods of updating that are far less ideal and can be confusing to new users.

Describe the solution you'd like

I propose we change the way the auto-updater functions on Windows in one of two ways:

  1. Rename the old pnpm.exe and download a new pnpm in its place. Then before exit use a cmd or powershell command to delete the old file cleaning up installation.
  2. Rename the old pnpm.exe and download a new one in its place, then use RunOnce to auto delete the file the next time the computer starts up.
  3. Rename the old pnpm.exe and download a new one in its place, then have pnpm check for preexisting binaries and remove them when it starts up.

I'm leaning more towards option two as it makes the most sense and is the most seamless. It's also unlikely you would have any handles open to the old binary on system startup.

Describe the drawbacks of your solution

  • Having different execution paths based on the platform.
  • Although mostly stable, the first solution could introduce a race condition where cmd/powershell could still fail to delete it.
  • The third introduces an additional step for pnpm to execute making it slightly slower to execute.

Describe alternatives you've considered

No response