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

Automatic install makes zsh to hang forever #25

Open
thom4parisot opened this issue Jun 24, 2018 · 7 comments
Open

Automatic install makes zsh to hang forever #25

thom4parisot opened this issue Jun 24, 2018 · 7 comments

Comments

@thom4parisot
Copy link

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?

@f
Copy link
Owner

f commented Jun 25, 2018 via email

@thom4parisot
Copy link
Author

thom4parisot commented Jun 25, 2018

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

@f
Copy link
Owner

f commented Jun 25, 2018 via email

@thom4parisot
Copy link
Author

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

@f
Copy link
Owner

f commented Jun 25, 2018 via email

@kangweichan
Copy link

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 nodejs/node#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.

@thom4parisot
Copy link
Author

Nice finding @kangweichan!

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

No branches or pull requests

3 participants