Skip to content

fix(shim): dispatch Windows executables from version dir root, respect NVM_DIR - #118

Merged
mose-zm merged 1 commit into
mainfrom
dev
Aug 23, 2026
Merged

mose-zm merged 1 commit into
mainfrom
dev

Conversation

@mose-zm

@mose-zm mose-zm commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the tracked P0 (note/p0-windows-shim-bin-path.md): on Windows, node/npm/npx via PATH were broken in Full Shim mode — every dispatch through shims\*.cmd failed with nvm: node not found.

Root cause (empirically reproduced in a controlled layout, 100% repro):

  • Windows Node archives put executables at the version dir root (version_bin_dir() returns the root for exactly this reason)
  • the shim dispatcher's :resolve only checked %NVM_DIR%\%CURRENT%\bin\ — a directory that never exists on Windows
  • PATH order is shims;active;bin, so the broken dispatcher always won resolution before the working active junction
  • secondary bug: the shim set NVM_DIR=%USERPROFILE%\.nvm.rust unconditionally, clobbering custom NVM_DIR

Fix

  • :resolve now checks the version dir root first (.exe then .cmd), keeping bin\ as fallback — applied to both copies of the script (src/shim.rs + install.ps1)
  • NVM_DIR guard: if not defined NVM_DIR set ...
  • quoted set "BIN=..." in install.ps1 (spaces in paths)

Tests

  • src/shim.rs: root-before-bin ordering + NVM_DIR guard content tests
  • tests/win_shim_dispatch.rs: install.ps1 content assertions + a Windows end-to-end test — real nvm refresh generates the shims against a root-layout fake version dir, then dispatching shims\node.cmd --version must succeed (this exact scenario failed before the fix)

Test plan

  • cargo fmt --check / clippy -D warnings / cargo test --all green locally (18 groups)
  • Manual repro confirmed broken before / fixed after
  • CI green on Ubuntu / Windows / macOS

@mose-zm
mose-zm merged commit 9928936 into main Aug 23, 2026
5 checks passed
@mose-zm
mose-zm deleted the dev branch August 23, 2026 05:57
@mose-zm mose-zm mentioned this pull request Aug 23, 2026
2 tasks
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.

1 participant