zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
2.95k stars 126 forks source link

[bug]: some `zinit update` errors appears after commit `1d4d38b` #408

Closed dec0dOS closed 1 year ago

dec0dOS commented 1 year ago

What happened?

Please check the Relevant output section

Seems that the following commit is relevant

Steps to reproduce

  1. Install zinit with brew on macOS
  2. Run zinit update

Relevant output

❯ zinit update
Assuming --all is passed
Updating Zinit…
Note: updating also unloaded snippets

Updating snippet: OMZP::docker-compose/_docker-compose
Downloading `OMZP::docker-compose/_docker-compose` (with curl, wget, lftp)…
.zinit-download-file-stdout:34: no such file or directory: /opt/homebrew/opt/zinit/share/single-line.zsh
Note: Compiling: _docker-compose… OK.
Installed 0 completions. They are stored in $INSTALLED_COMPS array.
Skipped installing 1 completions. They are stored in $SKIPPED_COMPS array.

Updating snippet: OMZP::docker/_docker
Downloading `OMZP::docker/_docker` (with curl, wget, lftp)…
.zinit-download-file-stdout:34: no such file or directory: /opt/homebrew/opt/zinit/share/single-line.zsh
Note: Compiling: _docker… OK.
Installed 0 completions. They are stored in $INSTALLED_COMPS array.
Skipped installing 1 completions. They are stored in $SKIPPED_COMPS array.

Updating snippet: OMZP::yarn/_yarn
Downloading `OMZP::yarn/_yarn` (with curl, wget, lftp)…
.zinit-download-file-stdout:34: no such file or directory: /opt/homebrew/opt/zinit/share/single-line.zsh
Note: Compiling: _yarn… OK.
Installed 0 completions. They are stored in $INSTALLED_COMPS array.
Skipped installing 1 completions. They are stored in $SKIPPED_COMPS array.

Note: updating also unloaded plugins
Updating b4b4r07/enhancd
Updating romkatv/powerlevel10k
Updating zdharma-continuum/fast-syntax-highlighting
Updating zdharma-continuum/zinit-annex-as-monitor
Updating zdharma-continuum/zinit-annex-bin-gem-node
Updating zdharma-continuum/zinit-annex-patch-dl
Updating zdharma-continuum/zinit-annex-rust
Updating zsh-users/zsh-autosuggestions
Updating zsh-users/zsh-completions
The update took 15.76 seconds

Screenshots and recordings

No response

Operating System & Version

OS: darwin22.0 | Vendor: apple | Machine: x86_64 | CPU: arm64 | Processor: arm | Hardware: arm64

Zsh version

zsh 5.9 (arm-apple-darwin21.3.0)

Terminal emulator

xterm-256color

If using WSL on Windows, which version of WSL

No response

Additional context

No response

Code of Conduct

vladdoster commented 1 year ago

good catch on this, thank you for reporting

  1. Mind sharing your config (do not see any public config in your repos)?

  2. Are consistently seeing this issue?

If yes, have you ran:

zi self-update

regardless, i'll try to reproduce it in zunit tests to improve confidence in future changes.

currently, the majority of current tests are for ices. will try to get this fixed ASAP.

dec0dOS commented 1 year ago

Thanks for your fast and detailed response, @vladdoster!

zinit self-update command does not fix the issue.

vladdoster commented 1 year ago

see if its resolved when you run:

exec zsh -l

or

exec zsh -il

finally, a hail mary (also genuine bug triage)

zi delete --all --yes \
&& unset $_comp \
&& exec zsh -l
dec0dOS commented 1 year ago

The same error persists with the first two commands. The third one does not work as expected

Screenshot 2022-11-03 at 01 42 15
dec0dOS commented 1 year ago

Here is my trimmed version of .zshrc:

# If not running interactively, don't do anything
[[ -o interactive ]] || return

## ----------------------------------------
##  Prompt
##  - Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
##  - Initialization code that may require console input (password prompts, [y/n]
##  confirmations, etc.) must go above this block; everything else may go below
## ----------------------------------------
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

## ----------------------------------------
##  Env
## ----------------------------------------
export SAVEHIST=0
export CLICOLOR=1
export ENHANCD_FILTER=fzf
export TERM=xterm-256color
export BAT_THEME="ansi"
export HOMEBREW_NO_COMPAT=1
export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_AUTO_UPDATE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export PYTHONSTARTUP=~/.pythonrc
export NODE_REPL_HISTORY=""
export PATH="$PATH:/Users/alex/.local/bin"

## ----------------------------------------
##  Editor
## ----------------------------------------
export EDITOR=nvim
export GIT_EDITOR="${EDITOR}"
export SVN_EDITOR="${EDITOR}"

## ----------------------------------------
##  Language
## ----------------------------------------
export LANGUAGE="en_US.UTF-8"
export LANG="${LANGUAGE}"
export LC_ALL="${LANGUAGE}"
export LC_CTYPE="${LANGUAGE}"

## ----------------------------------------
##  Option & Function
## ----------------------------------------
bindkey -e
setopt no_beep
setopt nolistbeep
setopt auto_cd
setopt auto_list
setopt auto_menu
setopt auto_param_keys
setopt auto_param_slash
setopt auto_pushd
setopt complete_aliases
setopt correct
setopt equals
setopt extended_glob
setopt list_packed
setopt list_types
setopt mark_dirs
setopt magic_equal_subst
setopt no_hup
setopt prompt_subst
setopt auto_remove_slash

## ----------------------------------------
##  iTerm2
## ----------------------------------------
if [ "$TERM_PROGRAM" = "iTerm.app" ]; then
  [ -f ~/.iterm2_shell_integration.zsh ] && source ~/.iterm2_shell_integration.zsh
fi

## ----------------------------------------
##  Homebrew
## ----------------------------------------
if type brew &>/dev/null
then
  FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
  autoload -Uz compinit
  compinit
fi

## ----------------------------------------
##  Zinit
## ----------------------------------------
source $(brew --prefix)/opt/zinit/zinit.zsh
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
zinit wait lucid for \
  atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
    zdharma-continuum/fast-syntax-highlighting \
  blockf \
    zsh-users/zsh-completions \
  atload"!_zsh_autosuggest_start" \
    zsh-users/zsh-autosuggestions
zinit ice wait'0'
zinit wait lucid is-snippet as"completion" for \
  OMZP::docker/_docker \
  OMZP::docker-compose/_docker-compose \
  OMZP::yarn/_yarn

## ----------------------------------------
##  Misc settings
## ----------------------------------------
zstyle ':completion:*:(ssh):*' hosts $hosts
zstyle ':completion:*:(ssh):*' users $users

### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
    print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
    command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
    command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
        print -P "%F{33} %F{34}Installation successful.%f%b" || \
        print -P "%F{160} The clone has failed.%f%b"
fi

source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

## ----------------------------------------
##  Prompt
##  - Must be the end of .zshrc.
##  - To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
## ----------------------------------------
zinit ice depth=1
zinit light romkatv/powerlevel10k
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

If anything is wrong with my .zshrc, I would be grateful for any suggestions.

vladdoster commented 1 year ago

The same error persists with the first two commands. The third one does not work as expected

Screenshot 2022-11-03 at 01 42 15

Doh, I forgot the s in _comps!

zi delete --all --yes \
&& unset _comps \
&& exec zsh -l
vladdoster commented 1 year ago

I'm perplexed why you source zinit.zsh in two separate places.

It looks like a Zinit install via Brew. I assume the formulae run the installer script, which added the second set of setup steps.

Am I correct in this assumption?

first instance of zinit init

# ----------------------------------------
# Zinit
# ----------------------------------------
source $(brew --prefix)/opt/zinit/zinit.zsh
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
zinit wait lucid for \
  atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
    zdharma-continuum/fast-syntax-highlighting \
  blockf \
    zsh-users/zsh-completions \
  atload"!_zsh_autosuggest_start" \
    zsh-users/zsh-autosuggestions
zinit ice wait'0'
zinit wait lucid is-snippet as"completion" for \
  OMZP::docker/_docker \
  OMZP::docker-compose/_docker-compose \
  OMZP::yarn/_yarn

Regarding the config above:

  1. the wait ice can not be used with the for syntax.
zinit wait lucid is-snippet as"completion" for \
  OMZP::docker/_docker \
  OMZP::docker-compose/_docker-compose \
  OMZP::yarn/_yarn
  1. Given the aforementioned issue, zinit ice wait'0' should be removed. The snippet might create a race condition of sorts causing the reported error.

My other hypothesis is that the two zinit locations are out of sync, but variables are getting twisted. Thus causing one version to try to refer to various things in a different version? I forget if zinit looks for the zinit repo in HOMEBREW or if it sets env variables.

I'll get back to you on this.

Not sure if that makes sense, but... yeah.

second instance of zinit init

### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
    print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
    command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
    command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
        print -P "%F{33} %F{34}Installation successful.%f%b" || \
        print -P "%F{160} The clone has failed.%f%b"
fi

source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
vladdoster commented 1 year ago

Oh, I'm dumb. I didn't realize the logs showed the homebrew path.

IMO, don't manage zinit with Brew. I am a die-hard Homebrew user, but it doesn't warrant nor leverage any of Brew's features. Furthermore, the formulae have no HEAD defined, so I think you're stuck on v3.7 since the release doesn't bundle the .git/ directory.

Screenshot 2022-11-03 at 04 23 43
dec0dOS commented 1 year ago

Thanks a lot, @vladdoster! Seems that the problem was with the brew installation and the incorrent .zshrc configuration. I've followed all your recommendadtions above and it is working as expected now.

It was working great for a long time, so I didn't borther some mistakes that was made priviously in the .zshrc.

Regarding the brew formula - if you does not recommend the bunduled version, may be it should be updated to install from HEAD by default or deperecated to remove the confusion?

Buy the way, event after installing the zinit from HEAD (brew uninstall zinit && brew install --force --HEAD --fetch-HEAD zinit) currently there are some new issues with the zinit.

vladdoster commented 1 year ago

@dec0dOS, I just cut release v3.8.0.

If you run:

brew uninstall --force zinit && brew install --force --HEAD --fetch-HEAD zinit

should now include all the latest changes!