zdharma-continuum / zinit

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

🐞 bug: zinit update breaks atclone file generation #172

Closed jankatins closed 2 years ago

jankatins commented 2 years ago

Issue description

I run zinit update and this breaks my starship setup as it seems the atclone stanza is not rerun after updating the program:

After an update via zsh -c "source ~/.zinit/bin/zinit.zsh && zinit update"

ls -la .zinit/plugins/starship---starship
total 5432
drwxr-xr-x 1 js js      46 Jan 31 12:36 .
drwxr-xr-x 1 js js    1006 Jan 30 13:58 ..
drwxr-xr-x 1 js js      50 Jan 31 12:36 ._backup
-rwxr-xr-x 1 js js 5561504 Jan 15 12:26 starship
drwxr-xr-x 1 js js     108 Jan  7 15:17 ._zinit

After rm -rf .zinit/plugins/starship---starship/ and opening a new terminal tab:

ls -la .zinit/plugins/starship---starship
total 5448
drwxr-xr-x 1 js js      80 Jan 31 12:43 .
drwxr-xr-x 1 js js    1006 Jan 31 12:43 ..
drwxr-xr-x 1 js js       0 Jan 31 12:43 ._backup
-rw-r--r-- 1 js js      89 Jan 31 12:43 init.zsh
-rw-r--r-- 1 js js   11305 Jan 31 12:43 _starship
-rwxr-xr-x 1 js js 5561504 Jan 15 12:26 starship
drwxr-xr-x 1 js js     108 Jan 31 12:43 ._zinit

zinit config

zinit wait lucid for \
          as"program" from"gh-r" \
          atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \
          atpull"%atclone" src"init.zsh" \
          load starship/starship

zinit version or commit ID

789eb023b10764392739831061d0b4b336aa227c

zsh version

5.8

host info

CPUTYPE=x86_64 MACHTYPE=x86_64 XDG_SESSION_TYPE=wayland OSTYPE=linux-gnu 5.15.0-2-amd64 ID=debian

yodahuang commented 2 years ago

This shall be the same bug as in #147

smac89 commented 2 years ago

For me atclone seems to be running after the commands it is supposed to proceed.

For example trying to add stripe cli completion:

zi wait='1b' lucid light-mode for \
     id-as="stripe/completion" \
        as="completion" \
        has='stripe' \
        atclone="stripe completion --shell zsh" \
        mv="stripe-completion* -> _stripe" \
        atpull="%atclone" \
        blockf zdharma-continuum/null

The mv command will run before atclone is finished because it will complain that no files matched, but when the install is finished, you will find that the file is actually there

zaggash commented 2 years ago

I had the same issue for completion with atclone atpull and kubectl The completion is not loading and stays uninstalled like in #147

I found a workaround:

zinit delete --clean
zinit cclear
zinit wait lucid for \
  as"completion" https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker \
  as"completion" has"kubectl" id-as"kubectl--completion" atpull'%atclone' atclone"kubectl completion zsh > _kubectl; zinit creinstall -q kubectl--completion" run-atpull nocompile zdharma-continuum/null

Maybe it'll help someone.

vladdoster commented 2 years ago

@smac89

For me atclone seems to be running after the commands it is supposed to proceed.

For example trying to add stripe cli completion:

zi wait='1b' lucid light-mode for \
     id-as="stripe/completion" \
        as="completion" \
        has='stripe' \
        atclone="stripe completion --shell zsh" \
        mv="stripe-completion* -> _stripe" \
        atpull="%atclone" \
        blockf zdharma-continuum/null

The mv command will run before atclone is finished because it will complain that no files matched, but when the install is finished, you will find that the file is actually there

You're overcomplicating things, look at stripe completion --help

zi for \
    as'completion' \
    atpull'%atclone' \
    blockf \
    from'gh-r' \
    nocompile \
    atclone"./stripe completion --shell zsh --write-to-stdout > _stripe" \
    sbin'stripe' \
  stripe/stripe-cli

Installing completion and zinit update --urge work fine.

An added benefit is it also installs the stripe cli binary, cool!

~/.local/share/zsh/zinit/plugins
ᐳ zi delete stripe/stripe-cli -y; exec zsh; zi report stripe/stripe-cli
bin-gem-node annex: Correctly removed the stripe shim from $ZPFX/bin

Done (action executed, exit code: 0)

Downloading stripe/stripe-cli…
(Requesting `stripe_1.8.1_linux_x86_64.tar.gz'…)
################################################################################################################################################################### 100.0%
ziextract: Unpacking the files from: `stripe_1.8.1_linux_x86_64.tar.gz'…
ziextract: Successfully extracted and assigned +x chmod to the file: `stripe'.
bin-gem-node annex: Created the stripe shim and set +x on the stripe binary
Installed 1 completions. They are stored in the $INSTALLED_COMPS array.

~/.local/share/zsh/zinit/plugins
ᐳ zi report stripe/stripe-cli
Report for stripe/stripe-cli plugin
-----------------------------------

Completions:
_stripe [enabled]

~/.local/share/zsh/zinit/plugins
jankatins commented 2 years ago

Given that I run my zinit update in a (non interactive) script, my original problem is (almost surely) fixed by #199 / #227. I'm closing this therefore.