topgrade-rs / topgrade

Upgrade all the things
GNU General Public License v3.0
1.93k stars 125 forks source link

zinit update fails to run mv"bin* -> bin" instructions #238

Open underyx opened 1 year ago

underyx commented 1 year ago

What did you expect to happen?

Running zinit update upgrades my zsh modules correctly, I expected the same from topgrade.

What actually happened?

I have these two modules in my zshrc that I noticed are affected:

zinit ice wait lucid from"gh-r" as"program" mv"gh* -> gh" pick"gh/bin/gh" \
  atclone='./gh/bin/gh completion --shell zsh > _gh' atpull'%atclone'
zinit load cli/cli

zinit ice \
  wait lucid from"gh-r" as"program" mv"direnv* -> direnv" \
  atclone'./direnv hook zsh > zhook.zsh' atpull'%atclone' \
  pick"direnv" src="zhook.zsh"
zinit load direnv/direnv

Whenever topgrade bumps the version of gh or direnv, I start getting these errors in my shell:

_direnv_hook:2: no such file or directory: /Users/underyx/.zinit/plugins/direnv---direnv/direnv

This is because the mv"direnv* -> direnv" instruction is supposed to make zinit rename this file to direnv after an update, but the rename doesn't happen (only when topgrade runs zinit update):

.zinit/plugins/direnv---direnv $ ls -ltr
total 18552
-rwxr-xr-x  1 underyx  staff  8861200 Nov 29 10:45 direnv.darwin-arm64

Additional Details

The rename happens correctly when I run zinit update in my shell.

The command executed for zinit is:

―― 11:01:58 - zinit ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
DEBUG Executing command `/bin/zsh -i -c 'source /Users/underyx/.zshrc && zinit self-update && zinit update --all'

which seems correct. I'm suspecting that for some reason in the subshell topgrade uses, the mv"direnv* -> direnv" instruction somehow gets glob expanded. If this is the case, then the asterisk should be passed to zinit verbatim for correct behavior. Or it might be the exact other way; maybe zinit normally relies on the shell resolving direnv* but this doesn't happen when running via topgrade.

You can find my dotfiles here: https://github.com/underyx/dotfiles

And specifically the zinit modules here: https://github.com/underyx/dotfiles/blob/main/zsh/main

s34m commented 1 year ago

Sorry for the late response, was stressed the last weeks.

What happens when you run this command: /bin/zsh -i -c 'source /Users/underyx/.zshrc && zinit self-update && zinit update --all'

underyx commented 1 year ago

hey, no worries at all! I just ran it (because I need to wait until an update is actually available for something to trigger the error) and it indeed caused the same issue!

underyx commented 1 year ago

I'll mention that there's another annoying behavior when using the command you provided (and also when running topgrade). The self-update prints its changelog with an interactive pager and everything is suspended until I press q to exit it. This doesn't happen if I remove the -i flag from the /bin/zsh command.