Skip to content

fix(command): resolve relative PATH entries against cwd - #2350

Open
RSS1102 wants to merge 2 commits into
voidzero-dev:mainfrom
RSS1102:rss1102/fix-relative-path-bin-resolution
Open

fix(command): resolve relative PATH entries against cwd#2350
RSS1102 wants to merge 2 commits into
voidzero-dev:mainfrom
RSS1102:rss1102/fix-relative-path-bin-resolution

Conversation

@RSS1102

@RSS1102 RSS1102 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve relative PATH entries against the command cwd before binary lookup
  • preserve PATH ordering, empty entries, and ~ expansion semantics
  • defensively normalize the resolved binary path
  • cover relative matches, fallback search, empty PATH entries, and tilde preservation

Problem

which::which_in searches relative PATH entries against the process cwd rather than the cwd supplied for the command. The npm-distributed CLI can therefore fail to resolve node when Vite+ git hooks prepend ./node_modules/.bin, even though the binary exists.

Validation

  • cargo test -p vp_command (17 passed)
  • cargo test -p vp_global_cli relative_path_entry (1 passed)
  • cargo clippy -p vp_command --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check
  • reproduced the failure with vite-plus@0.2.7 and a relative PATH entry, then verified the same command reaches vp check with the patched NAPI binding

Fixes #2326

@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 36c105b
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a742cbf821fa900080ba649

@RSS1102
RSS1102 marked this pull request as ready for review August 6, 2026 03:21
@RSS1102
RSS1102 force-pushed the rss1102/fix-relative-path-bin-resolution branch from b6e28ea to 990e718 Compare August 6, 2026 03:27
@RSS1102
RSS1102 marked this pull request as draft August 6, 2026 03:27
@RSS1102
RSS1102 marked this pull request as ready for review August 6, 2026 06:47
@fengmk2

fengmk2 commented Aug 6, 2026

Copy link
Copy Markdown
Member

@RSS1102 Can you add a snapshot test to cover this bug fix change?

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.

vp cannot resolve node through a relative PATH entry — breaks Vite+'s own git hooks

2 participants