Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#2,849 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
git, typescript
Área
cli, tooling

Línea de trabajo

Comienza en packages/cli/src/config/hooks.ts leyendo install() y los helpers gitConfigSet/gitConfigUnset. Reprodúcelo con los comandos de shell de linked-worktree y verifica después que los valores sin cambios omitan las escrituras y que las ejecuciones paralelas de vp config --no-agent terminen sin errores de config-lock, mientras que la configuración inicial siga escribiendo.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)

Lenguaje dominante
Rust
Estrellas
5.8k
Forks
267
Merge medio
20 h 30 min
PR fusionados (30 d)
144

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de voidzero-dev/vite-plus

Todos los issues de voidzero-dev/vite-plus

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.