Hook dispatcher breaks on Git for Windows when core.hooksPath is an absolute path
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Rust
- Stelle
- 6.3k
- Fork
- 283
- Merge medio
- 1g 16h
- PR unite (30g)
- 214
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di voidzero-dev/vite-plus
-
pending triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
voidzero-dev/vite-plus#2882 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
voidzero-dev/vite-plus#2097 · 10 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
defineConfig drops own properties of Promise plugins (breaks Vike discovery)Forse già presa @liangmiQwQ l’ha presa oggi. Apertabug
voidzero-dev/vite-plus#3152 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
vpx: watch reports for `vpx --watch`, and `vpx watch` on oxc-node's watcherForse già presa @fengmk2 l’ha presa oggi. Aperta
voidzero-dev/vite-plus#3141 · 1 reazione · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Document cross-platform `FOO=bar cmd` in task commands and scriptsForse già presa @hyunbinseo l’ha presa oggi. Apertadocumentation
voidzero-dev/vite-plus#3140 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di voidzero-dev/vite-plus
Issue simili
-
`rtk ruff -- <path>` drops the leading `--`, so `rtk ruff -- check` lints the whole directoryApertaarea:cli bug good first issue priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
rtk-ai/rtk#4702 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aaif-goose/goose#13031 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
meta.json, text.txt and try JSON are written non-atomicallyForse già presa @qwertymuzaffar l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
qwertymuzaffar/parrot#47 ·
I maintainer di solito rispondono entro 1 giorno
-
Alt select PhotocraftApertapriority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
storytold/photocraft#8041 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno