Skip to content

Fix broken Zinit completion links after plugin provisioning - #392

Merged
jiminu merged 3 commits into
mainfrom
fix/zinit-completion-staging
Oct 14, 2026
Merged

jiminu merged 3 commits into
mainfrom
fix/zinit-completion-staging

Conversation

@jiminu

@jiminu jiminu commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Zinit creates completion links and rebuilds its completion dump even when provisioning plugins with cloneonly. Selfishell v1.4.0 through v1.6.9 prepared checkouts in a temporary directory, so those links pointed at deleted staging paths after activation and caused intermittent compinit errors during rescans; the provisioning shell also deleted and rebuilt ~/.zcompdump.

Keep Zinit's completion directory and dump inside the private staging directory. During install and tools synchronization, remove dangling completion links whose target lies inside a former .selfishell-zinit.<digits> staging directory (matched by directory name, since Zinit records physical paths) and relink only _zinit to Zinit's installed file. Plugins add their own checkout to fpath, so retargeting the plugin links would only recreate the problem when a pin update drops an upstream completion file. User files, live or unrelated links, disabled completions, a completions directory replaced by a link, and dry-run behavior are preserved; a cleanup failure warns instead of stopping synchronization.

Validation:

  • bash scripts/check.sh: syntax, ShellCheck, formatting, Go vet, cross-builds, and all tests pass except TestNeovimDAPConfiguration, which fails identically on main in the local environment.
  • Mutation checks: removing each cleanup guard (underscore name, staging directory component and digits, dangling-only, replaced completions directory, _zinit relink), the private completion directory, or the cleanup call fails a test.
  • A probe sourcing the pinned Zinit with a temporary HOME showed the staging run previously created ~/.zcompdump and a dangling _zinit link, and creates neither after this change.

Plugins add their own checkout to fpath, so retargeted links into the final
checkout were redundant and would break again whenever a pin update drops an
upstream completion file. Remove dangling links into former staging
directories instead, matched by directory name because Zinit records physical
paths, and relink only _zinit to its installed file. Cleanup failures warn
rather than stopping tools synchronization.

The replaced path-mapping tests failed on macOS, where the temporary directory
is reached through the /var symlink.
Match only links whose target lies inside a `.selfishell-zinit.<digits>`
staging directory, not any path containing that text, and skip a completions
directory that the user replaced with a link.
@jiminu
jiminu merged commit cb3c1ac into main Oct 14, 2026
7 checks passed
@jiminu
jiminu deleted the fix/zinit-completion-staging branch October 14, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant