`vp config` rewrites unchanged git config on every run, so concurrent runs in linked worktrees fail with "could not lock config file"
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
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 whencore.hooksPathalready equals<target>git config --local --unset-all vp.hooks.disabled, even when the key is not setgit 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
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de voidzero-dev/vite-plus
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
voidzero-dev/vite-plus#2854 ·
Los mantenedores suelen responder en 1 día
-
pending triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
voidzero-dev/vite-plus#2801 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
voidzero-dev/vite-plus#2097 · 10 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
voidzero-dev/vite-plus#2850 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
voidzero-dev/vite-plus#2848 ·
Los mantenedores suelen responder en 1 día
Todos los issues de voidzero-dev/vite-plus
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 3 días
-
state:triage-needed
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Automattic/harper#4503 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
tobi/walgit#84 · 1 comentario ·
Los mantenedores suelen responder en 2 días