Zsh-autosuggestions: _zsh_autosuggest_strategy_default:5: error in flags

Created on 29 Nov 2017  路  36Comments  路  Source: zsh-users/zsh-autosuggestions

I am running zsh-autosuggestions from git/master

Since this morning all of my zsh shells are unusable because of the error message in $sub

Reverting to zsh-autosuggestions from earlier than 0.4.0 seems to fix it

Any suggestions on how to fix it so I can run zsh-autosuggestions latest again?

Most helpful comment

Ok, this should be fixed on master and released as v0.4.2. Thanks everyone for your feedback!

All 36 comments

Also affects me

What is the error message? I see the error message in the issue title now. What version of zsh? What OS? What are the contents of your .zshrc? Can you reproduce it running zsh -f and sourcing zsh-autosuggestions manually?

I'm not seeing these issues on zsh 5.4.2 on arch linux.

Also, do you get errors running either of these?

$ echo ${history[(r)ls*]}
$ foo="bar"; echo ${(b)foo}

centos7, Manual install or Oh My Zsh install both has the problem.
zsh autosuggestions version is 0.4.1.
help!

Same issue here with 0.4.1, running it as an oh-my-zsh plugin. Reverting to 0.4.0 solved the issue.

Running your second line gives an error:

$ echo ${history[(r)ls*]}
ls -l
$ foo="bar"; echo ${(b)foo}
zsh: error in flags

Amazon Linux 2017.09, latest OhMyZsh (commit e273cf004e1ff0510aee61416885f3003bcd15d9), zsh 5.0.2

Distribution - openSUSE Leap 42.3 and openSUSE Tumbleweed

zsh version 5.0.2 (Leap) or 5.3.1 (Tumbleweed)

Reproduced with zsh -f and sourcing zsh-autosuggestions manually

luke% echo ${history[(r)ls*]} luke% foo="bar"; echo ${(b)foo} _zsh_autosuggest_strategy_default:5: error in flags luke% foo="bar"; echo ${(b)foo}

zshrc https://github.com/sysrich/salt-states/blob/master/opensuse/zshrc-user

Please help, two days of no zsh is making me a sad bash-using panda 馃惣

Ok, thanks for the additional info everyone. It looks like support for the (b) flag was added relatively recently (released with zsh v5.0.8):

https://github.com/zsh-users/zsh/commit/6269db883ad6989a578bac299deab9c4285bb1df

This plugin doesn't currently support zsh versions older than v5.0.8: https://github.com/zsh-users/zsh-autosuggestions/blob/master/circle.yml#L3

The (b) flag was added to this plugin in commits 7f8ff28 and 5e4487e as a simplification of the pattern character escaping logic used when looking up suggestions. It also fixed some issues with the match_prev_cmd suggestion strategy.

The easiest fix here seems to be for you to upgrade zsh to v5.0.8 or higher, but if for some reason you can't, using v0.4.0 of this plugin is always available as a workaround. You could also define your own strategy function that doesn't use the (b) flag.

That being said, if a lot of people are unhappy with the workarounds and for some reason are not able to upgrade to v5.0.8 or higher, I would consider adding back the code that was removed by using the (b) flag and officially supporting versions of zsh older than v5.0.8. Toward that end, if anyone is stuck on a version older than 5.0.8 and isn't able to upgrade, can you add a note here with the version you're stuck on and an explanation of why you can't upgrade?

I'm running Tumbleweed, with zsh 5.3.1, and yet still having this problem. How can your suggestion that the solution to this is upgrading to 5.0.8?

Also on my Leap machines I cannot upgrade because 5.0.2 will be the only supported zsh version by my distro for another 2 years.

Can you double check that you're on 5.3.1? I can't imagine how this would be an issue with that version of zsh. From your shell session, you can echo $ZSH_VERSION.

No I can't, because echo $ZSH_VERSION results in _zsh_autosuggest_strategy_default:5: error in flags ;)

zypper if zsh however results in:

````
zypper if zsh
Loading repository data...
Reading installed packages...

Information for package zsh:

Repository : openSUSE-20150318-0
Name : zsh
Version : 5.3.1-1.6
````

No I can't, because echo $ZSH_VERSION results in _zsh_autosuggest_strategy_default:5: error in flags ;)

To get around this, you can temporarily remove zsh-autosuggestions from your zshrc or run zsh -f.

Looking into the details of the openSUSE zsh package now.

Update: Verified that that package does seem to bundle zsh v5.3.1: https://build.opensuse.org/package/show/openSUSE%3AFactory/zsh

Now I need to verify that the zsh that you're running is in fact the zsh provided by that package. It would be helpful if you can paste the output of running the following commands in your zsh environment:

$ echo $ZSH_VERSION
$ foo="bar"; echo ${(b)foo}

I've same problem in ubuntu 14.04 zsh 5.0.2

As noted before I am running on 5.0.2 and can't upgrade because that's the version provided by our distro (Amazon Linux). Manually upgrading is not an option due to compliance with security policies. In a business setting it will probably be very common to still run on 5.0.2 and it will not be possible to upgrade. :-(

I'm running Redhat Enterprise Linux 6 which has zsh version 4.3.11.
I can't switch to any newer version as this is not covered by support and there are no official packages available for RHEL6 and will never be.
On RHEL7 the zsh version is 5.0.2 and might at some day get an update to 5.0.8, but Redhat is quite conservative on this (for good reasons).

Problem also reproduced on SUSE Linux Enterprise Server and Desktop 12, another distro where updating to 5.0.8 is unlikely for a few years

Same for me on Debian Wheezy with zsh 5.4.2 compiled from source.

@ikirmitz Interesting. Does your compiled zsh support the (b) flag?

What is the output of these commands?

$ echo $ZSH_VERSION
$ foo="bar"; echo ${(b)foo}

Hi @ericfreese . Upon further checks, it turns out that although which zsh pointed to the one I compiled from source, $SHELL was pointing in an older version installed in /etc/alternatives (4.3.17).
I fixed that and now have no issues. Sorry for the confusion

i can''t write any words;help me

I use CentOS 7.4 and zsh v5.0.2 .
@nomike mentioned also, latest CentOS and REHL does not support zsh 5.0.8 (zsh 5.0.2 is supported and latest version...).
So users can't use latest package without source code building.

Ok. Given how common these old versions are, I'm intending to start officially supporting zsh versions back to v4.3.11 (as zsh-syntax-highlighting does).

I've pushed up a branch fixes/support_older_versions that attempts to run CI on these older versions, though I haven't got it working quite right yet...

PRs to that branch to improve support for older versions would be appreciated.

Thanks all

Does anyone know how to quit zsh? I cannot write any words (on my VPS server) now.

If zsh is your default shell you can't exit it (or rather it will terminate your connection). If you use ssh you can add a command to connect to your server: ssh [user@]host bash -l, that should give you a shell in which you can revert the plugin to the previous version.

How about

if $zshversion <= 5.0.8; then
    #old_code
else
    #new_code
fi

(pseudocode)
?
Or maybe that's already what branch fixes/support_older_versions is about.

Thanks @SunMar but when I used it, the server just complainedstdin: is not a tty.

@nomike That is a workaround, but just for when I can access my server, but by now, I can't. :-(

@Leetsong try it without the -l, it may looks like it is not doing anything but if you type something and hit enter you see you have a bash shell

@SunMar I've already tried before, but nothing happened except that it got stuck....

@Leetsong are you sure it got stuck? try typing ls -l, for me it's just a bash shell but with an empty prompt so it looks like it's stuck but you can actually enter commands as normal

@SunMar Yes, I am sure. Other commands works fine. I am now trying to use sed to delete words that do something with zsh-autosuggestions. :-) Thanks for your inspiring.

@Leetsong perhaps there is a way to start zsh without loading .zshrc or loading a non-existing file instead ? good luck :)

@SunMar @Leetsong You can run zsh with the -f flag to tell it not to source .zshrc at startup: zsh -f

@Leetsong:
You can try to allocate a pseudo terminal by executing
ssh -t user@hostname 'bash'
or if this fails reset the login shell using
ssh user@hostname 'chsh -s /bin/bash'

@nomike Thanks. You'v tought me another skill :-). And I have successfully fixed it using sed.

@ericfreese Thanks

For antigen users I pinned to an older version to fix my issues e.g.:

antigen bundles zsh-users/[email protected]

Tested on zsh 5.0.2

Ok, this should be fixed on master and released as v0.4.2. Thanks everyone for your feedback!

Was this page helpful?
0 / 5 - 0 ratings