Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#2,849 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
git, typescript
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Bắt đầu trong packages/cli/src/config/hooks.ts, đọc install() và các helper gitConfigSet/gitConfigUnset. Tái hiện bằng các lệnh shell của linked-worktree, sau đó xác minh rằng các giá trị không thay đổi sẽ bỏ qua việc ghi và các lần chạy song song của vp config --no-agent hoàn tất mà không gặp lỗi config-lock, trong khi thiết lập lần đầu vẫn ghi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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)

Ngôn ngữ chính
Rust
Star
5.8k
Fork
267
Merge trung bình
20 giờ 30 phút
Pull request đã merge (30 ngày)
144

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của voidzero-dev/vite-plus

Tất cả issue của voidzero-dev/vite-plus

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.