omelette icon indicating copy to clipboard operation
omelette copied to clipboard

Automatic install makes zsh to hang forever

Open thom4parisot opened this issue 7 years ago • 7 comments

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?

thom4parisot avatar Jun 24 '18 22:06 thom4parisot

Not sure. Can you please share what Omelette put into your zshrc file?

f avatar Jun 25 '18 04:06 f

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

thom4parisot avatar Jun 25 '18 11:06 thom4parisot

And what app --completion generates when you run?

f avatar Jun 25 '18 12:06 f

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

thom4parisot avatar Jun 25 '18 12:06 thom4parisot

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?

f avatar Jun 25 '18 13:06 f

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.

kangweichan avatar Jan 21 '21 00:01 kangweichan

Nice finding @kangweichan!

thom4parisot avatar Jan 21 '21 06:01 thom4parisot