zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
31.11k stars 1.86k forks source link

parse error near `_ZSH_AUTOSUGGEST_ASY...' #647

Open paul-vd opened 2 years ago

paul-vd commented 2 years ago

Describe the bug

With a clean install using oh-my-zsh, I get this error:

~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh:769: parse error near `_ZSH_AUTOSUGGEST_ASY...'

it seems to be related to any lines containing a <&-. If I comment everything inside the _zsh_autosuggest_async_request function, the issue moves over to line 826 which is

exec {1}<&-

If I comment that line, then I no longer receive any warnings.

To Reproduce

  1. Install oh-my-zsh (on mac m1 pro).
  2. Clone oh-my-zsh.
  3. Launch a terminal.

Expected behavior

Should not show an error

Desktop

ericfreese commented 2 years ago

Thanks @paul-vd. Are you able to reproduce this without oh-my-zsh? You can run zsh -df and then source the plugin manually with source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

paul-vd commented 2 years ago

Sorry, I meant to edit my original post, yea it works without oh-my-zsh

image

ericfreese commented 2 years ago

Interesting. Can you confirm your zsh version with echo $ZSH_VERSION?

paul-vd commented 2 years ago

v5.8, also after reporting this issue I did a complete uninstall of oh-my-zsh and reinstall but still the same issue.

ericfreese commented 2 years ago

Thanks. Do you get an error running these in zsh -df?

% exec {fd}<<(echo foo)
% exec {fd}<&-
paul-vd commented 2 years ago

No I don't get an error running those.

~Hmm I just restarted my mac and the error seems to have disappeared and the autosuggestions now work. 🤷‍♂️~ Doing source ~/.zshrc brings the error back up

ericfreese commented 2 years ago

Ah interesting. This may be something caused by sourcing your zshrc more than once. That's not generally recommended. To reload config changes you make to your zshrc file, just restart zsh in a new terminal instance or run exec zsh instead of running source ~/.zshrc

paul-vd commented 2 years ago

Yea so I just completely removed oh-my-zsh, reinstalled it, and added the plugin, but it is still the same issue, I'm not sourcing .zshrc from anywhere else, so it is indeed strange.