Hook dispatcher breaks on Git for Windows when core.hooksPath is an absolute path
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 72/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Rust
- Sterne
- 6.3k
- Forks
- 283
- Ø Merge
- 1 T. 12 Std.
- Gemergte PRs (30 T.)
- 235
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus voidzero-dev/vite-plus
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
voidzero-dev/vite-plus#3219 ·
Maintainer antworten meist innerhalb von 1 Tag
-
pending triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
voidzero-dev/vite-plus#2882 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
pending triage
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
voidzero-dev/vite-plus#3218 ·
Maintainer antworten meist innerhalb von 1 Tag
-
LSP loads vite.config.ts with the server's cwd as rootEvtl. vergeben @leaysgur hat das heute übernommen. Offenpending triage
voidzero-dev/vite-plus#3217 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
vp migrate doesn't flag esbuild-specific config (minify: "esbuild") — migrated project fails to build on Vite 8Evtl. vergeben @john-okeefe hat das vor 2 Tagen übernommen. Offencontribution welcome
voidzero-dev/vite-plus#3176 · 1 Reaktion · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in voidzero-dev/vite-plus
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
DayuanJiang/PecoFence#139 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
nearai/compose-manager#73 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
akitaonrails/ai-memory#1664 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag