Automatic install makes zsh to hang forever
Hello,
Great tool! I have had a great pleasure to use it to create my own autocomplete stuff :-)
I have used the .setupShellInitFile() function to automatically setup the shell autocompletion. However when I do so and run source ~/.zshrc, it hangs forever. I have to kill -9 the hanging process.
The added line in the .zshrc files is the following:
# .zshrc
. <(app --completion)
When I turn it into the following one, it does not hang and autocompletion works:
eval $(app --completion)
I am unsure about this issue. Do you have an idea?
Not sure. Can you please share what Omelette put into your zshrc file?
Of course 🙂
I use zsh (with zpresto) and this is the generated lines that have been added:
# begin app completion
. <(app --completion)
# end app completion
The source ~/.zshrc command hangs until I kill the process ID that is runs forever:
79804 ttys005 0:00.07 node /Users/oncletom/.nvm/versions/node/v10.4.0/bin/app --completion
And what app --completion generates when you run?
It generates the following — the app name I used before is in reality nodebook.ch08.omelette:
### nodebook.ch08.omelette completion - begin. generated by omelette.js ###
if type compdef &>/dev/null; then
_nodebook.ch08.omelette_completion() {
compadd -- `nodebook.ch08.omelette --compzsh --compgen "${CURRENT}" "${words[CURRENT-1]}" "${BUFFER}"`
}
compdef _nodebook.ch08.omelette_completion nodebook.ch08.omelette
elif type complete &>/dev/null; then
_nodebook.ch08.omelette_completion() {
local cur prev nb_colon
_get_comp_words_by_ref -n : cur prev
nb_colon=$(grep -o ":" <<< "$COMP_LINE" | wc -l)
COMPREPLY=( $(compgen -W '$(nodebook.ch08.omelette --compbash --compgen "$((COMP_CWORD - (nb_colon * 2)))" "$prev" "${COMP_LINE}")' -- "$cur") )
__ltrim_colon_completions "$cur"
}
complete -F _nodebook.ch08.omelette_completion nodebook.ch08.omelette
fi
### nodebook.ch08.omelette completion - end ###
Working fine to me, can you please remove all the snippets generated by Omelette and source the zshrc again to understand if really it's Omelette's fault?
Hi @f @oncletom I'm using omelette in a CLI I'm making and have just experienced the same issue during testing.
I managed to track down the exact problem and thought it may be useful for you to know. It turns out that . <(cli_command --completion) hangs/suspends when node is being run on version 12.5.0 and 12.6.0.
The fix for the issue in node 12.7.0 can be found at https://github.com/nodejs/node/pull/28535.
It would be nice for omelette to either detect those versions when installing and abort, or ideally to figure out a workaround piece of code to inject into the shell config file that works for all versions of node.
Nice finding @kangweichan!