zdharma-continuum / zinit

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

[bug]: .zinit-load:25: za-readurl-preinit-handler: function definition file not found #339

Closed iuliandita closed 2 years ago

iuliandita commented 2 years ago

Describe the bug

After a recent update, I get these messages every time I open a terminal, and I can't figure out where the issue comes from... Does anyone have any idea?

za-readurl-preinit-handler:179: parse error near `elif'
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load-snippet:63: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found
.zinit-load:25: za-readurl-preinit-handler: function definition file not found

Here's my zshrc:

##########
# zsh.rc #
##########

# enable to profile startup time, see last line too
#zmodload zsh/zprof

# increase ulimit
ulimit -n 4096

# disable ctrl-s ctrl-q
stty -ixon -ixoff

# zcache
zcachedir="$ZDOTDIR/.zcache"
[[ -d "$zcachedir" ]] || mkdir -p "$zcachedir"

# zinit
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
if [[ ! -f ${ZINIT_HOME}/zinit.zsh ]]; then
  print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
  command mkdir -p "${ZINIT_HOME}" && command chmod g-rwX "${ZINIT_HOME}"
  command git clone https://github.com/zdharma-continuum/zinit "${ZINIT_HOME}" && \
    print -P "%F{33}â–“â–’â–‘ %F{34}Installation successful.%f%b" || \
    print -P "%F{160}â–“â–’â–‘ The clone has failed.%f%b"
fi

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

# zinit annexes
zinit light-mode for \
  zdharma-continuum/z-a-rust \
  zdharma-continuum/z-a-as-monitor \
  zdharma-continuum/z-a-patch-dl \
  zdharma-continuum/z-a-bin-gem-node

# zinit plugins

# just in case the directory does not exist yet
[[ -d "$ZSH_CACHE_DIR/completions" ]] || mkdir -p "$ZSH_CACHE_DIR/completions"

# load omz plugins
zinit wait lucid for \
  OMZP::command-not-found \
  OMZP::helm \
  OMZP::kubectl \
  OMZP::kubectx \
  OMZP::ansible \
  OMZP::extract \
  OMZP::grc \
  OMZP::sudo \
  OMZP::fancy-ctrl-z \
  as"completion" \
    OMZP::vault/_vault \
  as"completion" \
    OMZP::terraform/_terraform \
  as"completion" \
    OMZP::docker/_docker \
  as"completion" \
    OMZP::docker-compose/_docker-compose \
  as"completion" \
    OMZP::fd/_fd

# Load random plugins from the interwebs
zinit wait lucid for \
  wfxr/forgit \
  MichaelAquilina/zsh-you-should-use \
  unixorn/fzf-zsh-plugin \
  zsh-users/zsh-history-substring-search

# enable starship prompt
zinit ice as"command" from"gh-r" \
  atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \
  atpull"%atclone" src"init.zsh"
zinit light starship/starship

# source external files
externals=("options" "bindkeys" "exports" "aliases" "completions" "functions")
for external in "${externals[@]}"; do
  [[ -s "$ZDOTDIR/$external" ]] \
  && source "$ZDOTDIR/$external"
done

# autocomplete stuff
# trying to speed up things
autoload -U +X bashcompinit && bashcompinit
fpath=(${ZINIT_HOME}/plugins/zsh-users---zsh-completions/src/ $fpath)
fpath+="${ZDOTDIR:-~}/.config/zsh/comp"
_comp_options+=(globdots) # With hidden files

_update_zcomp() {
  setopt local_options
  zstyle ':compinstall' filename "$ZDOTDIR/.zshrc"
  autoload -Uz compinit
  local zcompf="$1/zcompdump"
  # use a separate file to determine when to regenerate, as compinit doesn't
  # always need to modify the compdump
  local zcompf_a="${zcompf}.augur"

  if [[ -e "$zcompf_a" && -f "$zcompf_a"(#qN.md-1) ]]; then
      compinit -C -d "$zcompf"
  else
      compinit -d "$zcompf"
      touch "$zcompf_a"
  fi
  # if zcompdump exists (and is non-zero), and is older than the .zwc file,
  # then regenerate
  if [[ -s "$zcompf" && (! -s "${zcompf}.zwc" || "$zcompf" -nt "${zcompf}.zwc") ]]; then
    # since file is mapped, it might be mapped right now (current shells), so
    # rename it then make a new one
    [[ -e "$zcompf.zwc" ]] && mv -f "$zcompf.zwc" "$zcompf.zwc.old"
    # compile it mapped, so multiple shells can share it (total mem reduction)
    # run in background
    zcompile -M "$zcompf" &!
  fi
}
_update_zcomp "$zcachedir"
unfunction _update_zcomp

# need to load fzf-tab after compinit and before the other 3
zinit wait lucid for \
  Aloxaf/fzf-tab \
  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

# use beam shape cursor for each new prompt.
_fix_cursor() {
    echo -ne '\e[5 q'
}
precmd_functions+=(_fix_cursor)

#zprof

Steps to reproduce

The issue started after an update.

Expected behavior

No error message.

Screenshots and recordings

No response

Operating System & Version

linux-gnu | pc | x86_64 | x86_64 | x86_64 unknown (arch linux)

Zsh version

zsh 5.9 (x86_64-pc-linux-gnu)

Terminal emulator

xterm-256color (alacritty)

If using WSL on Windows, which version of WSL

No response

Additional context

No response

iuliandita commented 2 years ago

I cleaned up the zinit folder and after, it worked out, not sure what happened with the update...

vladdoster commented 2 years ago

@iuliandita This isn't the appropriate place for this issue.

The issue was reported and fixed in the read-URL annex repository. See zinit-annex-readurl/issues/11.

Regardless, thank you for taking the time to open the issue :^).