Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

`vp config` rewrites unchanged git config on every run, so concurrent runs in linked worktrees fail with "could not lock config file"

Geschlossen Anfängerfreundlich
#2,849 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@naokihaba arbeitet bereits daran.

Seit 05.10.2026.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
84/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
git, typescript
Bereich
cli, tooling

Rechercherichtung

Beginne in packages/cli/src/config/hooks.ts und lies install() sowie die Hilfsfunktionen gitConfigSet/gitConfigUnset. Reproduziere das mit den Shell-Befehlen für verknüpfte Worktrees und überprüfe anschließend, dass unveränderte Werte Schreibvorgänge überspringen und parallele Aufrufe von vp config --no-agent ohne config-lock-Fehler abgeschlossen werden, während die erstmalige Einrichtung weiterhin schreibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug
Describe the bug

install() in packages/cli/src/config/hooks.ts writes git config on every run, even when every value is already what it would write:

  • git config core.hooksPath <target>, even when core.hooksPath already equals <target>
  • git config --local --unset-all vp.hooks.disabled, even when the key is not set
  • git config --local vp.hooks.dir … / vp.hooks.prefix …, even when the stored values are equal

Linked worktrees share one .git/config, and each write takes git's config.lock. So two vp config runs at the same time, in different worktrees of one clone, collide and one fails:

error: could not lock config file /path/to/repo/.git/config: File exists

When the run comes from a prepare script, the package manager reports a lifecycle failure (ERR_PNPM_EXECUTOR_LIFECYCLE_SCRIPT_FAILED) and the install fails. This happens whenever worktrees are set up in parallel, for example by several coding agents that each create a worktree and install.

Reproduction

No project files needed, only a clone with a second worktree:

mkdir repro && cd repro && git init -q && git commit -q --allow-empty -m init
git worktree add -q ../repro-wt HEAD
vp config --no-agent                       # first run: sets core.hooksPath once
for i in $(seq 1 20); do
  vp config --no-agent >/dev/null 2>&1 || echo FAIL &
  (cd ../repro-wt && vp config --no-agent >/dev/null 2>&1 || echo FAIL) &
  wait
done | wc -l

On my machine this prints 18. Nothing needs to change after the first run, so the expected result is 0.

Suggested fix

Compare before writing, so a run that changes nothing never takes the lock (this keeps a relative core.hooksPath verbatim too):

 function gitConfigSet(key, value) {
+  if (gitConfigGet(key, { local: true }) === value) return { ok: true };
   ...
 }
 function gitConfigUnset(key) {
+  if (gitConfigGet(key, { local: true }) == null) return { ok: true };
   ...
 }
 // install()
-  const { status, stderr } = spawnSync('git', ['config', 'core.hooksPath', location.target]);
+  const { status, stderr } = existingHooksPath === location.target
+    ? { status: 0, stderr: '' }
+    : spawnSync('git', ['config', 'core.hooksPath', location.target]);

With this applied to the 1.0.0 dist as a local patch, 3 parallel runs × 10 rounds gave 0 failures, against 7/10 failures unpatched with 2 in parallel. A first-ever run in a clone still writes, but that happens once per clone rather than once per worktree setup.

System Info
  • vite-plus 1.0.0 (global and local)
  • git 2.55.0, macOS (Darwin 27)
Used Package Manager

pnpm (12.8.0)

Vorherrschende Sprache
Rust
Sterne
6.5k
Forks
296
Ø Merge
1 T. 12 Std.
Gemergte PRs (30 T.)
229

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus voidzero-dev/vite-plus

Alle Issues in voidzero-dev/vite-plus

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.