zpm icon indicating copy to clipboard operation
zpm copied to clipboard

does not work with zsh-users/zsh-syntax-highlighting

Open zUnixorn opened this issue 2 years ago • 8 comments

when adding zpm load @github/zsh-users/zsh-syntax-highlighting,source:zsh-syntax-highlighting.zsh to the .zshrc I get this error:

(anon):43: no such file or directory: /home/jonas/.version
(anon):44: no such file or directory: /home/jonas/.revision-hash
zsh-syntax-highlighting: highlighters directory '/home/jonas/highlighters' not found.
zsh-syntax-highlighting: failed loading highlighters, exiting.

When I type zpm clean it works again, but when I start a new shell its throwing this error again. I tried adding path:/highlighters but that didn't change anything.

Do you know what i'd need to change to get it working with zpm?

plugin source: https://github.com/zsh-users/zsh-syntax-highlighting/

zUnixorn avatar Feb 21 '22 16:02 zUnixorn

Please, update zpm first

grigorii-horos avatar Feb 23 '22 08:02 grigorii-horos

I just downloaded zpm when posting the issue, so it is up-to-date. And doing zpm upgrade also didn't help.

zUnixorn avatar Feb 23 '22 16:02 zUnixorn

Hm... Very strange. I just tested in clean env, and all works great. image

grigorii-horos avatar Feb 23 '22 19:02 grigorii-horos

image

grigorii-horos avatar Feb 23 '22 19:02 grigorii-horos

I tried it on three different distros (Void Linux, Arch Linux and Debian) and in every test I first ran exec zsh -d -f and then

if [[ ! -f ~/.local/share/zpm/zpm.zsh ]]; then
  git clone --recursive https://github.com/zpm-zsh/zpm ~/.local/share/zpm
fi
source ~/.local/share/zpm/zpm.zsh

zpm @github/zsh-users/zsh-syntax-highlighting,source:zsh-syntax-highlighting.zsh

and I got the same error on all three distros.

I am unsure what could be the cause of these different results, zsh -d -f should yield a clean enviornment so that shouldn't be the cause.

zUnixorn avatar Feb 24 '22 20:02 zUnixorn

did you restart the shell and tried it again? Because when I stay in the same session everything works fine, like in your example. But when I close it I get that error, doing zpm clean and the zpm load fixes it for the current session, restarting it makes the error come up again...

zUnixorn avatar Feb 24 '22 20:02 zUnixorn

@grigorii-horos @zUnixorn I also encountered this problem.That problem is due to /tmp/zsh-1000. The cache directory. I add

[ -d /tmp/zsh-1000/ ] && rm -rf /tmp/zsh-1000/*

before source zpm/zpm.zsh. And it works

jqhr avatar Mar 04 '22 00:03 jqhr

@grigorii-horos have the same problem with some plugins, Could you, please, take a look if you can fix the issues with them?

zpm load b4b4r07/enhancd
Result after opening a new shell:
__enhancd::init::init:5: no matches found: /tmp/zsh-1000/src/*.sh
zpm load zsh-users/zsh-history-substring-search
Result after opening a new shell:
(anon):source:3: No such file or directory: /home/user/zsh-history-substring-search.zsh

With other plugin managers they work fine.

avently avatar Mar 20 '22 18:03 avently

This error occurs with zsh-syntax-highlighting and zsh-autosuggestions. The underlying problem appears to be the resolution of the filename itself.

For zsh-syntax-highlighting the problem occurs here: https://github.com/zsh-users/zsh-syntax-highlighting/blob/1386f1213eb0b0589d73cd3cf7c56e6a972a9bfd/zsh-syntax-highlighting.zsh#L38-L43

This is then the cause of the errors

(anon):43: no such file or directory: /home/jonas/.version
(anon):44: no such file or directory: /home/jonas/.revision-hash

Which is present in the original post (so they had that plugin too heh). The problem appears to be that the file that is loaded is within the /home/jonas folder (i.e. the folder containing the .zshrc file).

This is fundamentally due to the zpm-cache.zsh file that is produced. This is a combination of all of the commands required to load the plugins. This file sets $0 at the beginning of each function that is defined (the functions being a way to compartmentalize each installed plugin). This set is then overwritten by the original code in the plugin later on which breaks.

bw-matthew avatar Aug 04 '23 14:08 bw-matthew

Fixed in main

grigorii-horos avatar Mar 04 '24 13:03 grigorii-horos