Skip to content

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

Open
RSS1102 wants to merge 10 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 10 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 41ed9c9
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a7b14cd359cf600082be3c2

@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?

@RSS1102
RSS1102 marked this pull request as draft August 7, 2026 02:45
@RSS1102
RSS1102 force-pushed the rss1102/fix-relative-path-bin-resolution branch from 7abfc83 to 4e44ec1 Compare August 7, 2026 02:55
@RSS1102
RSS1102 marked this pull request as ready for review August 8, 2026 12:58
@RSS1102 RSS1102 closed this Aug 8, 2026
@RSS1102 RSS1102 reopened this Aug 8, 2026
@fengmk2

fengmk2 commented Aug 9, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 2f15b4260e

ℹ️ 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".

@fengmk2 fengmk2 self-assigned this Aug 9, 2026
Comment thread crates/vp_command/src/lib.rs Outdated
@fengmk2

fengmk2 commented Aug 11, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af66713e7c

ℹ️ 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".

Comment thread crates/vp_command/src/lib.rs Outdated
@fengmk2

fengmk2 commented Aug 11, 2026

Copy link
Copy Markdown
Member

@codex review

@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw labels Aug 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb1cd60261

ℹ️ 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".

path_entry: &Path,
cwd: &AbsolutePath,
) -> Option<std::path::PathBuf> {
if path_entry.starts_with("~") || !is_plain_relative_path(path_entry) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve empty Windows PATH entries against the command cwd

On Windows, an empty PATH entry has no components, so is_plain_relative_path returns false and this branch delegates it to which; that lookup still interprets the empty entry relative to the vp process cwd rather than the selected command cwd. Consequently, when PATH contains a leading, trailing, or doubled ; and the executable exists only in the package cwd, vp exec --filter ... fails to resolve it. Treat the empty entry like the Unix branch does and search cwd/bin_name directly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think an empty Windows PATH entry should be resolved against cwd. On Windows, which intentionally ignores empty entries produced by leading, trailing, or consecutive semicolons—for example, the empty entry between ;; in C:\tools;;C:\Windows\System32. This matches Rust’s Windows command lookup behavior.

This PR only changes how non-empty relative entries such as tools, ./tools, and ../tools are resolved, so the empty-entry test is intentionally Unix-only.

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

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: sfw

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