Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erratic behavior of zcompile with zsh/param/private #3

Closed
Jackenmen opened this issue Oct 5, 2021 · 10 comments
Closed

Erratic behavior of zcompile with zsh/param/private #3

Jackenmen opened this issue Oct 5, 2021 · 10 comments

Comments

@Jackenmen
Copy link

I get this error message on startup:

(anon):22: bad pattern: funcs=(\n      ~zsh-autocomplete/functions/.autocomplete.*~*.zwc(N-.:a)\n  )
Cannot source /home/ubuntu/.zcomet/repos/marlonrichert/zsh-autocomplete/zsh-autocomplete.plugin.zsh.
ubuntu-virtual-machine% 

Contents of .zshrc:

# Clone zcomet if necessary
if [[ ! -f ${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh ]]; then
  command git clone https://github.com/agkozak/zcomet.git ${ZDOTDIR:-${HOME}}/.zcomet/bin
fi

source ${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh

zcomet load marlonrichert/zsh-autocomplete

See the response from zsh-autocomplete's author claiming that this is in fact a bug in zcomet:
marlonrichert/zsh-autocomplete#335 (comment)

@marlonrichert
Copy link

I don't just claim it, I can actually demonstrate it in a reproducible way:

% cd $(mktemp -d)
git clone --depth 1 -- https://github.com/agkozak/zcomet.git $PWD/.zcomet/bin
> .zshrc <<EOF
PS1="%# " PS2="  " RPS2="< %^"; setopt transientrprompt
source $PWD/.zcomet/bin/zcomet.zsh
zcomet load marlonrichert/zsh-autocomplete
EOF
env -i HOME=$PWD ZDOTDIR=$PWD FPATH=$FPATH TERM=$TERM zsh -d

/tmp/tmp.EZGp1Vxc1f/
Cloning into '/tmp/tmp.EZGp1Vxc1f/.zcomet/bin'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 25 (delta 2), reused 13 (delta 2), pack-reused 0
Receiving objects: 100% (25/25), 511.18 KiB | 412.00 KiB/s, done.
Resolving deltas: 100% (2/2), done.
Cloning marlonrichert/zsh-autocomplete:
Cloning into '/tmp/tmp.EZGp1Vxc1f/.zcomet/repos/marlonrichert/zsh-autocomplete'...
remote: Enumerating objects: 3247, done.
remote: Counting objects: 100% (950/950), done.
remote: Compressing objects: 100% (488/488), done.
remote: Total 3247 (delta 654), reused 729 (delta 451), pack-reused 2297
Receiving objects: 100% (3247/3247), 4.18 MiB | 1.33 MiB/s, done.
Resolving deltas: 100% (2289/2289), done.
(anon):22: bad pattern: funcs=(\n      ~zsh-autocomplete/functions/.autocomplete.*~*.zwc(N-.:a)\n  )
Cannot source /tmp/tmp.EZGp1Vxc1f/.zcomet/repos/marlonrichert/zsh-autocomplete/zsh-autocomplete.plugin.zsh.
% zcompile -R .zcomet/repos/marlonrichert/zsh-autocomplete/zsh-autocomplete.plugin.zsh
% exec zsh -d
%

Now zsh-autocomplete works just fine.

@marlonrichert
Copy link

See the response from zsh-autocomplete's author claiming that this is in fact a bug in zcomet:
marlonrichert/zsh-autocomplete#335 (comment)

Or rather, please read my comment on the same bug in Z Init.

@agkozak
Copy link
Owner

agkozak commented Oct 5, 2021

@jack1142 Thanks for your patience. I'm sure I'll have this fixed soon.

@marlonrichert You're right to point to the compiled wordcode as the source of the problem, and your demonstration works for me. But even changing my original zcompile -UzR to zcompile -R in zcomet.zsh doesn't fix the problem; running zcompile -R on the command line does. It will be interesting to figure out what's happening differently inside the zcomet.zsh script.

@marlonrichert
Copy link

But even changing my original zcompile -UzR to zcompile -R in zcomet.zsh doesn't fix the problem

Sorry, I missed that you were already using the -R flag to compile scripts. I just assumed you were doing the exact same thing as Z Init, as your plugin manager produced the exact same error. My bad.

@marlonrichert
Copy link

marlonrichert commented Oct 5, 2021

Never mind: On further investigation, it turns out that, actually, the only thing that fixes the problem, for both Z Init and Z Comet, is to zcompile from the command line. Changing the zcompile statement inside the code does nothing to solve it. There must be something that both of them change about the compilation progress, but I don't know what it is. 😕

@agkozak
Copy link
Owner

agkozak commented Oct 5, 2021

@marlonrichert

Very mysterious. I'll look forward to figuring out the root cause.

In the meantime, I've changed the _zcomet_compile function so that it ignores zsh-autocomplete.plugin.zsh. zsh-autocomplete should now work perfectly with zcomet while our investigations continue.

@jack1142 Be sure to run

rm -f ~[zsh-autocomplete]/zsh-autocomplete.plugin.zsh.zwc

That will get rid of the offending wordcode.

@agkozak
Copy link
Owner

agkozak commented Oct 6, 2021

As far as I can tell, simply running zcompile in an anonymous function on the command line

() { zcompile -R zsh-autocomplete.plugin.zsh; }

will also produce the error (when the script is sourced)

(anon):22: bad pattern: funcs=(\n      ~zsh-autocomplete/functions/.autocomplete.*~*.zwc(N-.:a)\n  )

No plugin manager involved.

@agkozak
Copy link
Owner

agkozak commented Oct 6, 2021

@jack1142 Did that help?

@Jackenmen
Copy link
Author

Error is gone.

@agkozak
Copy link
Owner

agkozak commented Oct 6, 2021

Glad to hear it! Thanks for helping to make zcomet better.

@agkozak agkozak closed this as completed Oct 6, 2021
@agkozak agkozak changed the title zsh-autocomplete fails to load with zcomet Erratic behavior of zcompile with zsh/param/private Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants