Hook dispatcher breaks on Git for Windows when core.hooksPath is an absolute path
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Start by reading the generated .vite-hooks/_/h script described in the issue, then locate the code that generates it and any related hook tests. Reproduce on Windows with Git for Windows using an absolute core.hooksPath. Done means the generated dispatcher handles that path correctly and git commit runs the repository's hook without the reported module error or silently falling back to a global vp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version: vite-plus 1.3.0 (global vp 1.2.0), Git for Windows 2.54.0, Node 22.23.1, Windows 11.
What happens
When core.hooksPath is an absolute Windows path such as C:\repo\.vite-hooks\_, every hook fails:
Error: Cannot find module 'C:\Program Files\Git\Users\me\repo\node_modules\vite-plus\bin\vp'
VITE+ - pre-commit script failed (code 1)
Some tools set an absolute path on purpose. For example, worktree managers point linked worktrees at the main checkout's dispatcher, because the generated .vite-hooks/_ is gitignored and missing in a new worktree.
Cause
The generated .vite-hooks/_/h derives the repo root from $0 and prepends it to PATH:
d="$(dirname "$(dirname "$(dirname "$0")")")"
export PATH="$d/node_modules/.bin:$PATH"
Git for Windows passes $0 as a drive-letter path, so d is C:\repo or C:/repo. sh splits the PATH entry at the drive colon into C and \repo\node_modules\.bin:
- With backslashes, sh finds the pnpm shim through the drive-relative path. The shim then passes
/repo/...to Node, which MSYS maps under the Git install root, giving the MODULE_NOT_FOUND above. - With forward slashes, the entry doesn't resolve, and
vpsilently falls back to whatever else is on PATH (here, the global~/.vite-plus/bin/vp).
Repro
- On Windows with Git for Windows, run
vp config --hooksin a repo whose pre-commit isvp staged. - Run
git config core.hooksPath "$(pwd -W)\.vite-hooks\_", or anyC:\...absolute value. - Run
git commit.
Suggested fix
Normalise d (or $0) to a POSIX path before building PATH, for example:
case "$d" in [A-Za-z]:*) command -v cygpath >/dev/null 2>&1 && d=$(cygpath -u "$d") ;; esac
Alternatively, avoid putting a path derived from $0 into PATH. Husky uses the cwd-relative node_modules/.bin.
Workaround we use (documented init script ~/.config/vite-plus/hooks-init.sh):
case "$0" in
[A-Za-z]:*)
if [ -z "${VP_HOOKS_POSIX_REEXEC-}" ] && command -v cygpath >/dev/null 2>&1; then
export VP_HOOKS_POSIX_REEXEC=1
exec sh "$(cygpath -u "$0")" "$@"
fi
;;
esac
- Ngôn ngữ chính
- Rust
- Star
- 6.3k
- Fork
- 283
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 208
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/vite-plus
-
`vp migrate --full` asks to set up pre-commit hooks even when they're already configuredCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởcontribution welcome
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
voidzero-dev/vite-plus#3096 · 1 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
voidzero-dev/vite-plus#2882 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
voidzero-dev/vite-plus#2097 · 10 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending triage
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 78/100
voidzero-dev/vite-plus#3110 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
voidzero-dev/vite-plus#3107 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/vite-plus
Issue tương tự
-
ci: SHA pin 3rd party actionsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Nushell launcher failure.Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Zellij doesn't validate hex colors correctly and crashesCó thể đã có người làm @ymcx đã nhận hôm nay. Đang mởsuspected bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
zellij-org/zellij#5732 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(api): E_DOSE_ATTR_NONFINITE for a modeled D/R still says the value "never reaches you as a NaN"Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100