helm: helm completion fails in zsh (prezto) with "bad math expression: operand expected"

I noticed helm completion in zsh is not working. One part of the problem is that _helm is not executable per default. Second when I type helm and hit tab I get:

helm _helm_root_command:12: bad math expression: operand expected at `"del"'

I found that removing the doublequotes in _helm at every aliashash key value fixes it. (/usr/local/Cellar/kubernetes-helm/2.12.0/share/zsh/site-functions/_helm)

not working:

aliashash["del"]="delete" 

fixed:

aliashash[del]="delete"

I am using prezto and I installed helm with homebrew.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 61
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

quick local fix in .zshrc…

source <(helm completion zsh | sed -E 's/\["(.+)"\]/\[\1\]/g')

hope it will fix in the next release. Current rc does not fix it

Still not fixed yet.

➜  ~ zsh --version
zsh --version
zsh 5.7.1 (x86_64-apple-darwin18.2.0)
➜  ~ helm version
helm version
Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}

Thanks to @arogarth and @koenpunt

I fixed this by changing file ~/.oh-my-zsh/plugins/helm/helm.plugin.zsh to:

if [ $commands[helm] ]; then
  source <(helm completion zsh | sed -E 's/\["(.+)"\]/\[\1\]/g')
fi

Having the same issue with helm v2.12.2:

$ source <(helm completion zsh)
$
# Typing 'helm' and hitting "Tab"
$ helm _helm_root_command:12: bad math expression: operand expected at `"del"'
$
$ helm version -c
Client: &version.Version{SemVer:"v2.12.2", GitCommit:"7d2b0c73d734f6586ed222a567c5d103fed435be", GitTreeState:"clean"}

Running ZSH under OSX:

$ zsh --version
zsh 5.3 (x86_64-apple-darwin17.0)

When installed through Homebrew you can use the following to fix autocompletion:

sed -i orig -E 's/\["(.+)"\]/\[\1\]/g' /usr/local/Cellar/kubernetes-helm/2.12.3/share/zsh/site-functions/_helm

Don’t forget to reload your shell; this can be done by opening a new window, or by running exec $SHELL

fixed via #5406, hopefully for real this time! 😄

Hey there, I was wondering when this change might make it in? Happy New Year.

@NZhuravlev this fix made it in after v2.12.3 shipped. You’ll unfortunately have to wait for the next release or build from source.

v2.12.3 - still have the same issue.

helm _helm_root_command:12: bad math expression: operand expected at `“del”’ macOS 10.14.2 (18C54) zsh 5.3 (x86_64-apple-darwin18.0) Client: &version.Version{SemVer:“v2.12.3”, GitCommit:“eecf22f77df5f65c823aacd2dbd30ae6c65f186e”, GitTreeState:“clean”}

@bacongobbler having the same issue with 2.13.0-rc.1:

$ source <(helm completion zsh)
$
# Typing 'helm' and hitting "Tab"
$ helm _helm_root_command:12: bad math expression: operand expected at `"del"'
$
$ helm version -c
Client: &version.Version{SemVer:"v2.13.0-rc.1", GitCommit:"e0e5197f8d9b3fa13626a273ad8b3f49a8aab67e", GitTreeState:"clean"}
$
$ zsh --version
zsh 5.3 (x86_64-apple-darwin18.0)