You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(env): regenerate all trampoline .exe files after upgrade (#1369)
During `vp upgrade`, only core shims (vp, node, npm, npx, vpx, vpr)
were refreshed. Package shims installed via `vp install -g` (e.g.,
corepack.exe, tsc.exe) kept stale trampoline binaries from the
previous version.
- Add `BinConfig::find_all_vp_source()` to discover package shims
- Add `refresh_package_shims()` to `vp env setup --refresh` (Windows)
- Fix `create_package_shim()` to re-copy trampoline on re-install
instead of returning early when .exe exists
- Make `rename_to_old` pub(crate) for reuse in global_install
Closes#1349
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes Windows shim generation/refresh and global package shim
overwrite behavior, which can affect command resolution and upgrade
stability. Scoped to Windows and mostly best-effort, but failures could
leave incorrect or stale shims.
>
> **Overview**
> Ensures Windows upgrades regenerate **all** trampoline shims, not just
core tools: `vp env setup --refresh` now discovers package-installed
binaries via `BinConfig` (`source: Vp`) and replaces their `<bin>.exe`
with the current trampoline.
>
> Updates global package install to always re-copy (or rename/delete
then copy) the trampoline `.exe` on re-install instead of skipping when
the shim already exists, and adds a shared `remove_or_rename_to_old`
helper to handle locked executables. Also centralizes `SHIM_TOOLS` in
`setup` and documents the new upgrade refresh behavior in the RFCs.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2d37595. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Copy file name to clipboardExpand all lines: rfcs/trampoline-exe-for-shims.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,6 +207,17 @@ When `vp env setup --refresh` is invoked through the trampoline (`~/.vite-plus/b
207
207
2. Copy new trampoline to `vp.exe`
208
208
3. Best-effort cleanup of all `*.old` files in the bin directory
209
209
210
+
### Upgrade Refresh
211
+
212
+
During `vp upgrade`, after the `current` link is swapped to the new version, `vp env setup --refresh` is invoked to regenerate all trampoline `.exe` files. This ensures that when the trampoline binary (`vp-shim.exe`) changes between versions, all shims pick up the new version:
213
+
214
+
1.**Core shims** (`vp.exe`, `node.exe`, `npm.exe`, `npx.exe`, `vpx.exe`, `vpr.exe`) are refreshed by the standard `--refresh` logic.
215
+
2.**Package shims** (e.g., `corepack.exe`, `tsc.exe`, installed via `vp install -g`) are discovered by scanning `~/.vite-plus/bins/` for `BinConfig` entries with `source: Vp`, and each `.exe` is replaced with the new trampoline.
216
+
217
+
Package shims installed via npm interception (`source: Npm`) use `.cmd` wrappers, not trampoline `.exe` files, and are not affected by this refresh.
218
+
219
+
Additionally, re-installing a global package (`vp install -g <pkg>`) always re-copies the current trampoline, ensuring the shim stays up to date even without a full upgrade.
220
+
210
221
### Distribution
211
222
212
223
The trampoline binary (`vp-shim.exe`) is distributed alongside `vp.exe`:
Copy file name to clipboardExpand all lines: rfcs/upgrade-command.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,7 +302,7 @@ Key differences on Windows:
302
302
303
303
After the symlink swap (the **point of no return**), post-update operations are treated as non-fatal. Errors are printed to stderr as warnings but do not trigger the outer error handler (which would delete the now-active version directory).
304
304
305
-
1.**Refresh shims**: Run the equivalent of `vp env setup --refresh` to ensure node/npm/npx shims point to the new version. If this fails, the user can run it manually.
305
+
1.**Refresh shims**: Run the equivalent of `vp env setup --refresh` to ensure node/npm/npx shims point to the new version. This also refreshes trampoline `.exe` files for globally installed package shims (e.g., `corepack.exe`, `tsc.exe`) by scanning `BinConfig` entries. If this fails, the user can run it manually.
306
306
2.**Cleanup old versions**: Remove old version directories, keeping the 5 most recent by **creation time** (matching `install.sh` behavior). The new version and the previous version are always protected from cleanup, even if they fall outside the top 5 (e.g., after a downgrade via `--rollback`).
0 commit comments