Skip to content

feat(env): make vp env off disable Node.js management for all vp commands#1255

Open
fengmk2 wants to merge 7 commits intomainfrom
real-node-off-mode
Open

feat(env): make vp env off disable Node.js management for all vp commands#1255
fengmk2 wants to merge 7 commits intomainfrom
real-node-off-mode

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Apr 1, 2026

Previously, vp env off only affected shim dispatch (node/npm/npx
invoked directly). All vp commands (create, build, install, etc.)
still downloaded managed Node.js via JsExecutor, ignoring the
system-first mode setting.

Now when vp env off is active, JsExecutor checks ShimMode before
downloading and uses the system-installed Node.js found in PATH.
This fixes NixOS/Guix (where downloaded binaries fail), air-gapped
environments, and users managing Node.js via other tools (mise, nvm).

  • Add JsRuntime::from_system() constructor for system binary paths
  • Add system-first checks to ensure_cli_runtime/ensure_project_runtime
  • Expose find_system_tool as pub(crate) and deduplicate doctor.rs copy
  • Update vp env off/on messaging to reflect broader scope
  • Add CI E2E tests for system-first mode on all platforms

Closes #977

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 1, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 0d4e245
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69cd2287787307000860d9ba

@fengmk2 fengmk2 self-assigned this Apr 1, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Apr 1, 2026


How to use the Graphite Merge Queue

Add the label auto-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

fengmk2 added 7 commits April 1, 2026 21:49
…mmands

Previously, `vp env off` only affected shim dispatch (node/npm/npx
invoked directly). All vp commands (create, build, install, etc.)
still downloaded managed Node.js via JsExecutor, ignoring the
system-first mode setting.

Now when `vp env off` is active, JsExecutor checks ShimMode before
downloading and uses the system-installed Node.js found in PATH.
This fixes NixOS/Guix (where downloaded binaries fail), air-gapped
environments, and users managing Node.js via other tools (mise, nvm).

- Add JsRuntime::from_system() constructor for system binary paths
- Add system-first checks to ensure_cli_runtime/ensure_project_runtime
- Expose find_system_tool as pub(crate) and deduplicate doctor.rs copy
- Update vp env off/on messaging to reflect broader scope
- Add CI E2E tests for system-first mode on all platforms

Closes #977
Verifies the full system-first mode lifecycle:
- `vp run` uses project's engines.node in managed mode
- `vp env off` switches to system-first mode
- `vp run` uses system Node.js instead of project version
- `vp env on` restores managed mode
Verifies the full system-first mode lifecycle with assertions:
- `assert-managed` passes in managed mode (uses engines.node 20.18.0)
- `vp env off` switches to system-first mode
- `assert-not-managed` passes (version is NOT 20.18.0)
- `vp env on` restores managed mode
- `assert-managed` passes again (back to 20.18.0)
The snap test command-env-off-on now covers system-first mode
switching with runtime assertions, making the CI E2E steps redundant.
…s active

Previously, `vp env doctor` always showed managed version resolution
(from .node-version, engines.node, etc.) even in system-first mode.
Now the Version Resolution section shows:
- Source: "system PATH"
- Version: actual system node version (from `node --version`)
- Node binary: system node path (e.g., /usr/local/bin/node)
…ands

- Rename "Shim Mode" to "Node.js Mode" throughout
- Update config.json comments to describe broader scope
- Update all doctor output examples (managed/system-first/unhealthy)
- Update vp env on/off command output examples
- Add NixOS, air-gapped, container, and multi-tool use cases
- Show Version Resolution section for system-first mode in doctor
Thread the system node path from check_shim_mode() into
check_current_resolution() instead of scanning PATH twice.

Also add debug_assert in JsRuntime::from_system() to catch
empty binary filenames from malformed paths.
@fengmk2 fengmk2 force-pushed the real-node-off-mode branch from 9ce4b34 to 0d4e245 Compare April 1, 2026 13:49
@fengmk2 fengmk2 marked this pull request as ready for review April 2, 2026 01:04
@fengmk2 fengmk2 requested review from branchseer and cpojer April 2, 2026 01:04
@cpojer
Copy link
Copy Markdown
Member

cpojer commented Apr 2, 2026

Question regarding vp env off's expected behavior. I'm trying to figure out if we need three different modes here. Does it still shim node.js inside of a project that uses Vite+?

I imagine that there might be use-cases for three things:

  • Vite+ does not manage Node.js → Always use system Node.js
  • Vite+ only manages Node.js inside of projects that use vite-plus → otherwise fall back to system Node.js
  • Vite+ always manages Node.js

Can you walk me through what our plan is exactly?

@fengmk2
Copy link
Copy Markdown
Member Author

fengmk2 commented Apr 2, 2026

Before this PR change:
vp env off only disables the interception when executing node, npm and other shims, which will fall back to the system version of Node.js.
For any commands run through the global vp cli within projects that depend on vite-plus, the node version used in the process will point to the version declared in .node-version (because this functionality existed before the vp env command).

After this PR change:
vp env off will disable all node shims, including the logic within projects that depend on vite-plus, all falling back to the system version of Node.js.

I think after the change there are only 2 modes: either intercept everything or fall back everything, without the current intermediate state.

As for falling back to vp management mode when system Node.js is not found, I think this is reasonable because we assume some new users will only install vp without installing Node.js first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support system Node.js for vp commands (not just shims)

2 participants