zdharma-continuum / zinit-packages

zinit package repository
https://zdharma-continuum.github.io/zinit/wiki/Zinit-Packages/
22 stars 3 forks source link

[bug]: package binary+keys for fzf does not config keybindings correctly. #8

Open albertfgu opened 2 years ago

albertfgu commented 2 years ago

Describe the bug

I'm experiencing the exact same bug as in https://github.com/zdharma-continuum/zinit-packages/issues/7

Steps to reproduce

Manually added zinit command inside the package and followed standard instructions to load zsh

Expected behavior

Same bug. Error message is

Downloading junegunn/fzf…
(Requesting `fzf-0.34.0-darwin_amd64.zip'…)
######################################################################## 100.0%
ziextract: Unpacking the files from: `fzf-0.34.0-darwin_amd64.zip'…
Archive:  fzf-0.34.0-darwin_amd64.zip
  inflating: fzf
ziextract: Successfully extracted and assigned +x chmod to the file: `fzf'.
fzf -> /Users/albertgu/.local/share/zinit/polaris/bin/fzf
.zinit-load-plugin:source:60: no such file or directory: /Users/albertgu/.local/share/zinit/plugins/junegunn---fzf/key-bindings.zsh

Screenshots and recordings

No response

Operating System & Version

darwin20.0 | apple | x86_64 | x86_64 | x86_64 i386

Zsh version

zsh 5.8 (x86_64-apple-darwin20.0)

Terminal emulator

xterm-256color

If using WSL on Windows, which version of WSL

No response

Additional context

No response

pschmitt commented 2 years ago

How is your config looking?

albertfgu commented 2 years ago

I created a minimal .zshrc

### 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

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
    zdharma-continuum/zinit-annex-as-monitor \
    zdharma-continuum/zinit-annex-bin-gem-node \
    zdharma-continuum/zinit-annex-patch-dl \
    zdharma-continuum/zinit-annex-rust

# fzf https://github.com/zdharma-continuum/zinit-packages/tree/main/fzf
# Same as `zinit pack"bgn-binary+keys" for fzf
# Installs using bgn annex (rename fzf util without modifying path), downloads binary instead of compile from scratch with Go, adds fzf keybindings
zinit \
    atclone'mkdir -p $ZPFX/{bin,man/man1}' \
    atpull'%atclone' \
    dl'https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh -> _fzf_completion;
      https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh -> key-bindings.zsh;
      https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf-tmux.1 -> $ZPFX/man/man1/fzf-tmux.1;
      https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf.1 -> $ZPFX/man/man1/fzf.1' \
    from'gh-r' \
    id-as'junegunn/fzf' \
    lucid \
    nocompile \
    pick'/dev/null' \
    sbin'fzf' \
    src'key-bindings.zsh' \
  for @junegunn/fzf

# Syntax highlighting, Autosuggestions, Completions
# From example http://zdharma-continuum.org/zinit/wiki/Example-Minimal-Setup/
# zinit wait"0b" lucid light-mode for \
zinit wait lucid light-mode for \
  atinit"zicompinit; zicdreplay" \
      zdharma-continuum/fast-syntax-highlighting \
  atload"_zsh_autosuggest_start" \
      zsh-users/zsh-autosuggestions \
  blockf atpull'zinit creinstall -q .' \
      zsh-users/zsh-completions

then ran rm -rf ~/.local/share/zinit && exec zsh and everything loads fine except fzf

Downloading junegunn/fzf…
(Requesting `fzf-0.34.0-darwin_amd64.zip'…)
########################################################################################################################################################################################################################### 100.0%
ziextract: Unpacking the files from: `fzf-0.34.0-darwin_amd64.zip'…
Archive:  fzf-0.34.0-darwin_amd64.zip
  inflating: fzf
ziextract: Successfully extracted and assigned +x chmod to the file: `fzf'.
bin-gem-node annex: Created the fzf shim and set +x on the fzf binary
.zinit-load-plugin:source:111: no such file or directory: /Users/albertgu/.local/share/zinit/plugins/junegunn---fzf/key-bindings.zsh

I then tried to use the snippet in the Recipes for popular programs

zi for \
    from'gh-r'  \
    as'null' \
    sbin'fzf'   \
  junegunn/fzf

zi for \
    https://github.com/junegunn/fzf/raw/master/shell/{'completion','key-bindings'}.zsh

and it loads fine:

Downloading junegunn/fzf…
(Requesting `fzf-0.34.0-darwin_amd64.zip'…)
########################################################################################################################################################################################################################### 100.0%
ziextract: Unpacking the files from: `fzf-0.34.0-darwin_amd64.zip'…
Archive:  fzf-0.34.0-darwin_amd64.zip
  inflating: fzf
ziextract: Successfully extracted and assigned +x chmod to the file: `fzf'.
bin-gem-node annex: Created the fzf shim and set +x on the fzf binary

Setting up snippet: https://github.com/junegunn/fzf/raw/master
Downloading `https://github.com/junegunn/fzf/raw/master` (with curl, wget, lftp)…
########################################################################################################################################################################################################################### 100.0%
Note: Compiling: completion.zsh… OK.

Setting up snippet: https://github.com/junegunn/fzf/raw/master
Downloading `https://github.com/junegunn/fzf/raw/master` (with curl, wget, lftp)…
########################################################################################################################################################################################################################### 100.0%
Note: Compiling: key-bindings.zsh… OK.

What's the difference between these two versions? Is there any reason to prefer the version inside zinit-packages?

haoyun commented 1 year ago

same prolem here on linux.

Downloading (pack'') junegunn/fzf… (at label: fzf…)
(Requesting `fzf-0.34.0-linux_amd64.tar.gz'…)
######################################################################################################################################################################################### 100.0%
ziextract: Unpacking the files from: `fzf-0.34.0-linux_amd64.tar.gz'…
ziextract: Successfully extracted and assigned +x chmod to the file: `fzf'.
'fzf' -> '/home/yun/.local/share/zinit/polaris/bin/fzf'
.zinit-load-plugin:source:60: no such file or directory: /home/yun/.local/share/zinit/plugins/fzf/key-bindings.zsh
zinit pack"binary+keys" for fzf

chaning profile have similar problems, e.g., with bgn+keys:

Package: fzf. Selected profile: bgn+keys. Available profiles: bgn, bgn+keys, bgn-binary, bgn-binary+keys, binary, binary+keys, default, default+keys.
Downloading tarball for fzf…

ziextract: Unpacking the files from: `0.28.0.tar.gz'…
ziextract: Successfully extracted and marked executable the appropriate files (fzf-tmux, install, uninstall) contained in `0.28.0.tar.gz'.
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
GOARCH=amd64 go build -a -ldflags "-s -w -X main.version=0.28.0 -X main.revision=zinit-pack" -tags "" -o target/fzf-linux_amd64
cp -f target/fzf-linux_amd64 bin/fzf
'man/man1/fzf.1' -> '/home/yun/.local/share/zinit/polaris/man/man1/fzf.1'
'man/man1/fzf-tmux.1' -> '/home/yun/.local/share/zinit/polaris/man/man1/fzf-tmux.1'
Running `make install`…
make: Entering directory '/home/yun/.local/share/zinit/plugins/fzf'
Makefile:15: *** Not on git repository; cannot determine $FZF_VERSION.  Stop.
make: Leaving directory '/home/yun/.local/share/zinit/plugins/fzf'
vladdoster commented 1 year ago

@haoyun i think this might be fixed. can you confirm this is still an issue?

albertfgu commented 1 year ago

Same issue still

.zinit-load-plugin:source:111: no such file or directory: /Users/albertgu/.local/share/zinit/plugins/junegunn---fzf/key-bindings.zsh
vladdoster commented 1 year ago

Same issue still


.zinit-load-plugin:source:111: no such file or directory: /Users/albertgu/.local/share/zinit/plugins/junegunn---fzf/key-bindings.zsh

ah, okay. will look into this.

haoyun commented 1 year ago

@haoyun i think this might be fixed. can you confirm this is still an issue?

I deleted ~/.local/share/zinit and reinstalled zinit with my old .zshrc. It works.

Package: fzf. Selected profile: binary+keys. Available profiles: bgn, bgn+keys, bgn-binary, bgn-binary+keys, binary, binary+keys, default, default+keys.
Note: The `bgn*` profiles (if any are available) are the recommended ones (the reason is that they expose the binaries provided by the package without altering (i.e.: cluttering…) the$PATH environment variable).

Downloading (pack'') junegunn/fzf… (at label: fzf…)
(Requesting `fzf-0.34.0-linux_amd64.tar.gz'…)
######################################################################################################################################################################################### 100.0%
ziextract: Unpacking the files from: `fzf-0.34.0-linux_amd64.tar.gz'…
ziextract: Successfully extracted and assigned +x chmod to the file: `fzf'.
[patch-dl annex]: File _fzf_completion downloaded correctly
[patch-dl annex]: File key-bindings.zsh downloaded correctly
[patch-dl annex]: File fzf-tmux.1 downloaded correctly
[patch-dl annex]: File fzf.1 downloaded correctly
'fzf' -> '/home/yun/.local/share/zinit/polaris/bin/fzf'
Installed 1 completions. They are stored in the $INSTALLED_COMPS array.
vladdoster commented 1 year ago

You shouldn't need to remove the zinit repository. Instead, run the following commands:

zi delete --all --yes
zi self-update
zsh -il

the ability to reinstall a plugin is a missing capability in zinit. additionally, I have a few aliases to do this, but I'll add the dedicated command(s) to zinit.

Source code link

alias zcln="command rm -rf ${HOME}/.{local/share/{zinit,zsh},cache,config/{zinit,zsh/.{zcomp{cache,dump},zsh_sessions}}}"
alias zreset="builtin cd ${HOME} && ( zcln && zrld ) && cd -"
alias zicln="zi delete --all --yes; ( exec zsh -il );"
alias zrld="builtin exec zsh -il"

Can we consider this issue closed?

haoyun commented 1 year ago
zi delete --all --yes
zi self-update
zsh -il

Thanks a lot!!!

Can we consider this issue closed?

For me, of course yes. I'm not sure if the problem was solved for @albertfgu .

albertfgu commented 1 year ago

After running those commands (I think previously I forgot to run the self-update), it now works.

Downloading junegunn/fzf…
(Requesting `fzf-0.34.0-darwin_amd64.zip'…)
######################################################################################################### 100.0%
ziextract: Unpacking the files from: `fzf-0.34.0-darwin_amd64.zip'…
Archive:  fzf-0.34.0-darwin_amd64.zip
  inflating: fzf
ziextract: Successfully extracted and assigned +x chmod to the file: `fzf'.
[patch-dl annex]: File _fzf_completion downloaded correctly
[patch-dl annex]: File key-bindings.zsh downloaded correctly
[patch-dl annex]: File fzf-tmux.1 downloaded correctly
[patch-dl annex]: File fzf.1 downloaded correctly
bin-gem-node annex: Created the fzf shim and set +x on the fzf binary
Installed 1 completions. They are stored in the $INSTALLED_COMPS array.

The command I used was the bgn+binaries command:

zinit \
    atclone'mkdir -p $ZPFX/{bin,man/man1}' \
    atpull'%atclone' \
    dl'https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh -> _fzf_completion;
      https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh -> key-bindings.zsh;
      https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf-tmux.1 -> $ZPFX/man/man1/fzf-tmux.1;
      https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf.1 -> $ZPFX/man/man1/fzf.1' \
    from'gh-r' \
    id-as'junegunn/fzf' \
    lucid \
    nocompile \
    pick'/dev/null' \
    sbin'fzf' \
    src'key-bindings.zsh' \
  for @junegunn/fzf

One last question I have: before getting this to work, I used the much simpler command

zi for \
    from'gh-r'  \
    as'null' \
    sbin'fzf'   \
  junegunn/fzf

zi for \
    https://github.com/junegunn/fzf/raw/master/shell/{'completion','key-bindings'}.zsh

which was modified from https://github.com/zdharma-continuum/zinit/wiki/Recipes-for-popular-programs#fzf.

Could someone explain the main differences between these? What are the reasons to prefer the much more complicated command provided by the zinit-packages here?

Lastly, how should I modify the command to source both key-bindings.zsh and completions.zsh?

vladdoster commented 1 year ago

zi delete --all --yes

zi self-update

zsh -il

Thanks a lot!!!

Can we consider this issue closed?

For me, of course yes. I'm not sure if the problem was solved for @albertfgu .

Whoops, I forgot the exec

zi delete --all --yes
zi self-update
exec zsh -il