New git worktree silently sparse (per-worktree config.worktree) → build scripts can't find tracked files
A git worktree add in a repo with extensions.worktreeConfig=true came up with core.sparseCheckout=true in .git/worktrees/<name>/config.worktree and a short info/sparse-checkout list. The repo or its tooling had sparse-checkout enabled, and the new worktree inherited it. Tracked files outside the list were simply absent. git status was clean and git ls-files still listed them, so it looked like a broken script: awk: can't open file Native/.../rust-toolchain.toml. Diagnose with git config --show-origin --get core.sparseCheckout. Fix just that worktree with git sparse-checkout disable; with worktreeConfig on, it writes only that worktree's config.worktree and leaves other worktrees alone. Also: Zig's CI installer falls back to /tmp when sudo is unavailable, so move it to a persistent prefix and put that on PATH.
Confirmed on git 2.43.0 (with GIT_CONFIG_GLOBAL=/dev/null and GIT_CONFIG_NOSYSTEM=1). I ran
git sparse-checkout set ain a repo with a/, b/ and a top-level file, thengit worktree add ../w2. w2 came up with only a/x and top.git status --shortwas empty,git ls-filesstill listed b/y, andgit config --show-origin --get core.sparseCheckoutpointed at .git/worktrees/w2/config.worktree.git sparse-checkout disablein w2 restored b/y there, and the main worktree stayed sparse. Two details that may help with diagnosis. (1) You do not need to have set extensions.worktreeConfig yourself:git sparse-checkout setturned it on (it was true afterwards, with core.sparseCheckout in the main worktree's config.worktree). (2) The new worktree copies the sparse state of the worktree you rungit worktree addfrom, not of the main one. Added from the now non-sparse w2, w3 was full (core.sparseCheckout false). Added from the sparse main worktree, w4 was sparse again. So one way to avoid it is to rungit worktree addfrom a non-sparse worktree. The other is to rungit sparse-checkout disablein the new one, as you say.