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(cli): keep env use session-scoped on Windows (#1577)
## Summary
- prevent `vp env use` on Windows from writing the shared
`.session-node-version` fallback
- require the PowerShell eval wrapper for Windows session-scoped env
switching
- ignore legacy session files from Windows runtime resolution and
surface them in `vp env doctor`
## Verification
- installed local dev CLI and verified direct Windows invocation no
longer creates `.session-node-version`
- verified separate wrapped PowerShell sessions can select Node 20.18.0
and 22.18.0 independently
<img width="1958" height="430" alt="image"
src="https://github.com/user-attachments/assets/ca2216d4-3b0e-4d1c-8559-f7c058ff5386"
/>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes Windows behavior for `vp env use` by preventing session-file
fallback outside CI and returning non-zero when the PowerShell eval
wrapper isn’t loaded, which could break existing Windows
workflows/scripts.
>
> **Overview**
> Ensures `vp env use` stays *session-scoped on Windows* by disallowing
`.session-node-version` writes in interactive Windows shells unless the
PowerShell wrapper is active (CI is still allowed to use the session
file fallback). `vp env use --unset` now always deletes any existing
session file, and new Windows-only tests cover direct invocation, CI
fallback, and wrapper cleanup behavior.
>
> Refactors env setup script generation in `env setup` into per-shell
templates with a shared renderer, and updates PowerShell setup
guidance/output (including docs and RFC) to explicitly dot-source
`"$env:USERPROFILE\.vite-plus\env.ps1"`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6e38069. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
// Users run `vp-use 24` in cmd.exe instead of `vp env use 24`
700
-
let vp_use_cmd_content = "@echo off\r\nset VP_ENV_USE_EVAL_ENABLE=1\r\nfor /f \"delims=\" %%i in ('%~dp0..\\current\\bin\\vp.exe env use %*') do %%i\r\nset VP_ENV_USE_EVAL_ENABLE=\r\n";
701
-
// Only write if bin directory exists (it may not during --env-only)
724
+
// Only write the cmd wrapper if bin directory exists (it may not during --env-only)
725
+
let bin_path = vite_plus_home.join("bin");
702
726
if tokio::fs::try_exists(&bin_path).await.unwrap_or(false){
703
-
let vp_use_cmd_file = bin_path.join("vp-use.cmd");
0 commit comments