Skip to content

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

Open
RSS1102 wants to merge 11 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 11 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 02d787f
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a7ee093fb9c3a000812309e

@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".

Comment thread crates/vp_command/src/lib.rs
@RSS1102

RSS1102 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@fengmk2 pls review again when you have time

[[case]]
name = "command_exec_relative_path_cwd"
vp = "local"
skip-platforms = ["windows"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why skip windows?

@fengmk2 fengmk2 added the preview-build Publish this PR's commits to the registry bridge as preview builds label Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-build Publish this PR's commits to the registry bridge as preview builds 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