Uh oh!
There was an error while loading. Please reload this page.
fix(cli): keep env use session-scoped on Windows - #1577
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
80bfa93 to
ab868d5CompareIHEL
commented
May 14, 2026
好的,请验证好功能,我的要求是跟fnm软件类似,在不同的PowerShell Tab窗口使用类似fnm use切换node版本,不影响其他的PowerShell Tab窗口里面的node版本,目前使用下来vp env use切换node版本其他PowerShell里面执行vp env list也跟着同步发送切换变化了,我希望跟fnm类似 |
dc48fe8 to
9072db7CompareIHEL
commented
May 14, 2026
这个功能大概什么时候发布正式? |
9072db7 to
c64eedaCompareUh oh!
There was an error while loading. Please reload this page.
fengmk2
commented
May 14, 2026
@IHEL A new version will be released every Tuesday. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…letes
- Remove the --use-no-cd flag: it was wired into the parser but never read
by print_shell_env, and env.ps1 has no directory-change hooks for it to
opt out of. Update the recommended PowerShell setup line everywhere
(cli help, print_path_instructions, wrapper-required warning, docs/RFC).
- Drop the duplicated config::delete_session_version() calls in use.rs:
the unconditional delete at the top of each branch already covers all
three sub-cases (eval-wrapper, session-file-allowed, Windows non-CI),
so the inner delete inside `else if can_use_session_file()` was a
guaranteed-NotFound syscall.
- Flatten three `else { if ... }` blocks into `else if ...` (silent-if-
unchanged, tail write block, unset branch) and drop the redundant
"Removed file-based ... if it existed" line that was superseded by the
existing "Reverted to file-based Node.js version resolution" message.
- Sync the `vp env --help` example for the PowerShell setup into
help.rs's hand-maintained mirror; the clap after_help in cli.rs is not
rendered for `vp env --help` (the unified renderer wins), so the
PowerShell example was previously invisible to users.The full `vp env --shell powershell | Out-String | Invoke-Expression` line is much longer than the other Setup examples, so leaving it inline broke the `#`-comment column alignment. Move it into its own `PowerShell (add to $PROFILE):` subsection (matches the existing Setup/Manage/Inspect/Execute structure) and drop the inline comment. Update the cli-helper-message snapshot to match.
Promote the previous top-level `--shell <shell>` flag on `vp env` into a
proper `Profile { shell: Option<EnvShell> }` subcommand so the new
capability fits the existing noun-verb subcommand pattern (current,
print, default, on, off, setup, doctor, which, pin, unpin, list, ...)
instead of being the only top-level flag on the command. The recommended
PowerShell setup invocation becomes:
vp env profile --shell powershell | Out-String | Invoke-Expression
Side-effect-free implementation:
- Lift the four shell env-file templates (POSIX/Fish/Nushell/PowerShell)
and the cmd.exe wrapper to module-scope constants in setup.rs.
- Add `setup::render_env_content(shell, vite_plus_home) -> String` as a
pure helper that performs the placeholder substitution for one shell.
- `create_env_files` now loops over the four shells calling the helper,
removing the inline-template duplication.
- `vp env profile` builds the content directly via `render_env_content`
and prints it. No call to `create_env_files`, no read-back of a file
we just wrote — important because the recommended `$PROFILE` line runs
on every PowerShell startup, which previously rewrote all five env
files (~20KB of disk churn) on every shell launch.
Also reverts `create_env_files` from `pub(crate)` back to private now
that the profile path no longer needs it, syncs help.rs subcommand list
+ Examples block, and updates the use.rs warning text plus docs/RFC.- Add `EnvShell::env_file_name() -> &'static str` so the per-shell file name (env, env.fish, env.nu, env.ps1) lives on the enum instead of the inline tuple in `create_env_files`. Removes one source of drift; the rest of the codebase (notably `commands/shell.rs::ALL_SHELL_PROFILES`) can migrate to this method in a follow-up. - Disambiguate the `print` subcommand description against the new `profile` subcommand in both clap (`vp env print --help`) and the unified renderer (`vp env --help`). The contrast between "current session" and "$PROFILE-style setup" is now explicit.
fengmk2
commented
May 14, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
`vp env setup` already writes `~/.vite-plus/env.ps1` to disk, so the new `vp env profile` subcommand was redundant: the recommended PowerShell `$PROFILE` line just needs to dot-source the existing file. That avoids spawning a `vp` subprocess on every shell startup, removes the chicken-and-egg requirement that `vp` already be on PATH, and matches the pattern used by rustup/mise/fnm/sdkman. . "$env:USERPROFILE\.vite-plus\env.ps1" Changes: - Remove `EnvSubcommands::Profile` and the `print_profile` handler. - Remove the `clap::ValueEnum` derive and `#[value(alias = ...)]` attributes on `EnvShell` — it is no longer exposed via the CLI, only used internally by `setup::create_env_files` / `render_env_content`. - Restore the original `print` subcommand description (the `profile` cross-reference is no longer needed). - Update the recommended PowerShell setup line everywhere (cli help examples, help.rs Examples block, print_path_instructions, the `print_windows_eval_wrapper_required` warning, docs/guide/env.md, rfcs/env-command.md). - Make `render_env_content` private again now that the `vp env profile` caller is gone; keep the lift-templates-to-consts cleanup since `create_env_files` still benefits.
Uh oh!
There was an error while loading. Please reload this page.
…ed hint - Relocate `EnvShell` enum and `env_file_name()` from `cli.rs` into `commands/env/setup.rs`. With `vp env profile` gone, the type is no longer CLI surface — only `create_env_files` and `render_env_content` use it. Drop `pub`/`pub(crate)` since callers are now same-module. - Reword `print_windows_eval_wrapper_required`: the previous "Then start a new PowerShell session" hint left the user's current PowerShell still wrapper-less. Updated to "dot-source it now (or open a new PowerShell session)" so the user can re-run `vp env use` without restarting the shell.
The PowerShell setup line is documented in docs/guide/env.md and the RFC; including it inline in the `vp env --help` Examples is noise for the common (POSIX) audience and was the only Windows-specific example in the block.
fengmk2
commented
May 15, 2026
@cursor review |
fengmk2
commented
May 15, 2026
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:6e38069500
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6e38069. Configure here.
`vp env setup` writes `env.ps1` under the actual `vite_plus_home`, but the printed PowerShell `$PROFILE` instruction was hardcoded to `$env:USERPROFILE\.vite-plus\env.ps1`. With a custom `VP_HOME` the file written and the file the user is told to dot-source did not match, so subsequent `vp env use` calls kept hitting the wrapper-required error even though setup succeeded. Use the same `home_path` already computed for the POSIX/Fish/Nushell instructions.
Uh oh!
There was an error while loading. Please reload this page.
Release vite-plus v0.1.22: Security Patch, Parallel Global Install & Scaffold Polish A critical Vitest browser-mode security fix, parallel `vp add -g` installs, a built-in oxlint rule to prefer `vite-plus` imports, and a new `--git` switch for `vp create`. ### Highlights - **Security**: bundled `vitest` bumped to `4.1.6` to address [GHSA-2h32-95rg-cppp](GHSA-2h32-95rg-cppp) (Critical, CVSS 9.6), an XSS to RCE chain via the `otelCarrier` query parameter in Vitest browser mode ([#1633](#1633)) - **Parallel global install**: `vp add/install/update -g` now installs packages concurrently with a progress bar and a `--concurrency` flag (default 5) ([#1597](#1597)) - **Prefer vite-plus imports**: new bundled oxlint rule rewrites `vite`/`vitest` imports to `vite-plus`, enabled by default in generated and migrated `lint` configs ([#1408](#1408)) - **Git init on scaffold**: `vp create` learns `--git`/`--no-git` (interactive prompt; auto-commits "Initial commit from Vite+") ([#1484](#1484)) ### Features - Spawn npm for global installation in parallel with a progress bar and a `--concurrency` option ([#1597](#1597)), by @liangmiQwQ - Add bundled oxlint rule to prefer `vite-plus` imports over `vite`/`vitest` ([#1408](#1408)), by @Han5991 - `vp create`: initialize a git repository and create an initial commit on scaffold ([#1484](#1484)), by @ryohidaka - `vp create`: rename underscore-prefixed files (`_gitignore`, `_npmrc`, `_yarnrc.yml`) to dotfiles for `@org/create` bundled templates ([#1574](#1574)), by @jong-kyung - Add `VP_PR_VERSION` env var to install unreleased PR builds via pkg.pr.new ([#1578](#1578)), by @fengmk2 ### Fixes & Enhancements - Skip merging standalone `.oxfmtrc`/`.oxlintrc` config when the `fmt:`/`lint:` key is already declared in `vite.config.ts` (fixes duplicate-block regression in `vp create fate`) ([#1601](#1601)), by @fengmk2 - Suppress the `VITE+ - The Unified Toolchain for the Web` banner for `vp lint --lsp`, `vp fmt --lsp`, and `vp fmt --stdin-filepath` so stdout stays a pure LSP / formatter stream ([#1619](#1619)), by @fengmk2 - `vp create`: detect output directory when running in the current directory ([#1606](#1606)), by @jong-kyung - `vp update -g`: skip installs when the recorded global package version already matches the npm-resolved version, and tolerate string/array outputs from `npm view ... version --json` ([#1596](#1596)), by @leno23 - `vp create`: preserve single-segment project path in `updateWorkspaceConfig` ([#1582](#1582)), by @jong-kyung - `vp env use`: keep the change session-scoped on Windows ([#1577](#1577)), by @fengmk2 - `vp rebuild`: accept positional package names ([#1564](#1564)), by @fengmk2 - Adopt the new vite-task error formatter; errors now print as `error: <top-level>` plus `* <source>` chain lines, with bold-red highlight on a TTY ([vite-task#390](voidzero-dev/vite-task#390)), by @branchseer - vite-task: forward `LOCALAPPDATA` so Node's compile cache stays outside the workspace on Windows ([vite-task#389](voidzero-dev/vite-task#389)), by @branchseer - Bump vite-task to `c945cc0` ([#1628](#1628)), by @branchseer ### Refactor - Revert `vp pm plugin` command (per discussion in #1038) ([#1623](#1623)), by @jong-kyung ### Docs - Add `vitepress-plugin-llms` to the docs site so the published docs include LLM-friendly outputs (`/llms.txt`) ([#1625](#1625)), by @jong-kyung - Refresh home stats for oxlint, vite, and vitest ([#1512](#1512)), by @nozomee - Mention `vp env doctor` in agent instructions ([#1603](#1603)), by @leno23 ### Chore - Consolidate the upstream build chain into a single `pnpm build` script (justfile recipe now just calls `pnpm build`) ([#1626](#1626)), by @fengmk2 - Fix bootstrap-cli on Windows ([#1583](#1583)), by @fengmk2 - Refresh trusted stack stats ([#1573](#1573), [#1616](#1616)), by @voidzero-guard[bot] - Update GitHub Actions ([#1611](#1611), [#1612](#1612)), by @renovate[bot] - Address zizmor findings in composite actions and the release workflow; drop unused `actions-cool/issues-helper` ([#1630](#1630)), by @Boshen - Switch plain checkouts to `taiki-e/checkout-action` ([#1620](#1620)), by @Boshen - Switch release to a version-bump PR + push trigger flow ([#1575](#1575)), by @Boshen - Gate release publish on environment approval with a Discord notice ([#1571](#1571)), by @Boshen - Enable `cargo clippy` with `-D warnings` ([#1579](#1579)), by @Boshen - Drop unused `setup-node` from the version-check job ([#1600](#1600)), by @fengmk2 - Add Void deploy workflows for the docs site ([#1590](#1590)), by @fengmk2 - Add `--help` case to config snap tests for npm10/yarn1/yarn4 ([#1585](#1585)), by @jong-kyung - Add `--help` case to publish snap tests for npm10/yarn1/yarn4 ([#1584](#1584)), by @jong-kyung - Verify `.gitignore` and `.yarnrc.yml` in the new-vite-monorepo snap ([#1576](#1576)), by @jong-kyung - vite-task: bump pnpm to `11.1.2` ([vite-task#383](voidzero-dev/vite-task#383)), by @branchseer - vite-task: update lint-staged to v17 ([vite-task#385](voidzero-dev/vite-task#385)), by @renovate[bot] ### Bundled Versions | Tool | Version | Source | | --- | --- | --- | | vite | `8.0.11` | [`66f3194`](vitejs/vite@66f3194) | | rolldown | `1.0.0` | [`ac5c710`](rolldown/rolldown@ac5c710) | | tsdown | `0.22.0` | [npm](https://npmx.dev/package/tsdown/v/0.22.0) | | vitest | `4.1.6` | [npm](https://npmx.dev/package/vitest/v/4.1.6) | | oxlint | `1.63.0` | [npm](https://npmx.dev/package/oxlint/v/1.63.0) | | oxlint-tsgolint | `0.22.1` | [npm](https://npmx.dev/package/oxlint-tsgolint/v/0.22.1) | | oxfmt | `0.48.0` | [npm](https://npmx.dev/package/oxfmt/v/0.48.0) | ### New Contributors Welcome to all new contributors! 🎉 @nozomee, @ryohidaka, @leno23 **Full Changelog**: v0.1.21...v0.1.22 --- Merging this PR will trigger the release workflow. --------- Co-authored-by: voidzero-guard[bot] <278573678+voidzero-guard[bot]@users.noreply.github.com> Co-authored-by: MK <fengmk2@gmail.com>
Summary
vp env useon Windows from writing the shared.session-node-versionfallbackvp env doctorVerification
.session-node-versionNote
Medium Risk
Changes Windows behavior for
vp env useby 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 usestays session-scoped on Windows by disallowing.session-node-versionwrites in interactive Windows shells unless the PowerShell wrapper is active (CI is still allowed to use the session file fallback).vp env use --unsetnow 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 setupinto 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".Reviewed by Cursor Bugbot for commit 6e38069. Configure here.