zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
2.9k stars 125 forks source link

[bug]: sourcing completion when generated in the `atpull` hook #147

Open yodahuang opened 2 years ago

yodahuang commented 2 years ago

Issue description

The generated _foo_bar completion file is being ignored by zinit.

E.g. when running zinit update kubectl_completion (see my config for the setup that is previously working),

[update] Continuing with the update because run-atpull'' ice given.
No files for compilation found.
Warning: ∞zinit-compile-plugin-hook hook returned with 1

Using zinit update kubectl_completion -u -r does not help.

zinit config

zinit lucid wait has"kubectl" for \ 
  id-as"kubectl_completion" as"completion" \ 
  atclone"kubectl completion zsh > _kubectl" \
atpull"%atclone" run-atpull zdharma-continuum/null 

zinit version or commit ID

9ee45d6804fdf4972a9e913a1ad86d77de124231

zsh version

5.8

host info

OSTYPE=linux-gnu CPUTYPE=x86_64 MACHTYPE=x86_64 5.4.0-1060-aws VERSION="18.04.6 LTS (Bionic Beaver)" ID=ubuntu

vladdoster commented 2 years ago

Thanks for reporting this @yodahuang! I'll take a look at this later tonight.

lljbash commented 2 years ago

Same for me.

My config:

zinit wait lucid depth=3 as"completion" blockf from"gh-r" light-mode for \
    mv"ripgrep* -> ripgrep" cp"ripgrep/comp*/_rg -> _rg" sbin"ripgrep/rg" \
    atclone"rm -rf ripgrep/comp*" atpull'%atclone' \
        BurntSushi/ripgrep

Test result:

1e6bdf0: broken

Downloading BurntSushi/ripgrep…
(Requesting `ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz'…)
######################################################################## 100.0%
ziextract: Unpacking the files from: `ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz'…
ziextract: Successfully extracted and assigned +x chmod to the file: `ripgrep-13.0.0-x86_64-unknown-linux-musl/rg'.
'ripgrep-13.0.0-x86_64-unknown-linux-musl' -> 'ripgrep'
Warning: ∞zinit-mv-hook hook returned with 1
'ripgrep/complete/_rg' -> '_rg'
Warning: ∞zinit-cp-hook hook returned with 1
No files for compilation found.
Warning: ∞zinit-compile-plugin-hook hook returned with 1
bin-gem-node annex: Created the rg shim and set +x on the rg binary

d82c613: good

Downloading BurntSushi/ripgrep…
(Requesting `ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz'…)
######################################################################## 100.0%
ziextract: Unpacking the files from: `ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz'…
ziextract: Successfully extracted and assigned +x chmod to the file: `ripgrep-13.0.0-x86_64-unknown-linux-musl/rg'.
'ripgrep-13.0.0-x86_64-unknown-linux-musl' -> 'ripgrep'
'ripgrep/complete/_rg' -> '_rg'
No files for compilation found.
bin-gem-node annex: Created the rg shim and set +x on the rg binary
Installed 1 completions. They are stored in the $INSTALLED_COMPS array.
vladdoster commented 2 years ago

oof, we broke zinit with a documentation update... lol. Looking into this now.

gotgenes commented 2 years ago

I just ran into this issue trying to use completions for poetry

zinit ice as"completion" id-as"poetry-completion" has"poetry" run-atpull \
    atclone"poetry completions zsh > _poetry" atpull"%atclone"
zinit light zdharma-continuum/null

I can see the file at ~/.zinit/plugins/poetry-completion/_poetry, however, it's not sourced and used for completions.

oof, we broke zinit with a documentation update... lol. Looking into this now.

@vladdoster Would you be willing to share any more information regarding this? Perhaps the suspect lines of code, or at least the commit or PR?

EDIT: I missed the commits listed by @lljbash above. So it seems like this was introduced in #112.

Is there a known workaround, in the meantime?

yodahuang commented 2 years ago

There's a workaround at https://github.com/zdharma-continuum/zinit/issues/172#issuecomment-1053682178, which basically says "ok zinit is not souceing the completion file for me, let me run zinit creinstall myself".

vladdoster commented 2 years ago

@gotgenes

I think your recipe for poetry completion is incomplete.

Try this:

zi for \
    as'completion' \
    atclone'poetry completions zsh > _poetry' \
    atpull'%atclone' \
    blockf \
    has'poetry' \
    id-as'python-poetry/poetry' \
    nocompile \
  zdharma-continuum/null
gotgenes commented 2 years ago

@vladdoster Thanks for your help! I believe the nocompile was critical here, but also I added the as'completion'. This now works for me:

zinit ice \
    as"completion" \
    id-as"poetry-completion" \
    has"poetry" \
    atclone"poetry completions zsh > _poetry" \
    atpull"%atclone" \
    run-atpull \
    nocompile
zinit light zdharma-continuum/null
mustaqimM commented 2 years ago

I believe the nocompile was critical here

@vladdoster How come this is needed? I also came across this with starship:

zi from"gh-r" bpick"*linux-gnu.tar.gz" nocompile fbin"starship" \
  atclone"./starship init zsh > init.zsh; zcompile init.zsh; \
  ./starship completions zsh > _starship" atpull"%atclone" for \
  "starship/starship"

The completion file _starship wasn't being linked until I added nocompile