ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.71k stars 1.26k forks source link

kubectx errors with Ubound Variable #322

Open Sodman opened 3 years ago

Sodman commented 3 years ago

Whenever I run kubectx I get the error message in the output: /usr/local/bin/kubectx: line 250: $@: unbound variable.

I assume this is a reference to https://github.com/ahmetb/kubectx/blob/3504e66edbe51e1bcbb57cd02b2cf6972e9d501d/kubectx#L250

I'm on MacOS (amd64 intel CPU).

kubectx version 0.9.4, installed via brew. Tried reinstalling, no difference.

Happens in both Bash and zsh.

FWIW, kubens also errors - with /usr/local/bin/kubens: line 226: $@: unbound variable

Any idea what might I might be missing in my env?

Edit: I should also add that kubectx some-context actually works fine, it's just the bare kubectx which should list all contexts which is failing for me.

ahmetb commented 3 years ago

There's a very decent chance your bash version has updated to a newer version that broke something. I cannot repro this right now. But if you provide a full output with DEBUG=1 env var set, I can take a look.

To unblock yourself, go to Releases tab and download the binary version of kubectx implemented in Go.

ahmetb commented 2 years ago

Last call to provide s repro with DEBUG=1.

Sodman commented 2 years ago

Thank you for the reminder, apologies for the delay, I had missed the original notification. I will grab latest and try to reproduce again tonight with DEBUG=1.

Sodman commented 2 years ago

Output with DEBUG=1:

$ DEBUG=1 kubectx
+ set -eou pipefail
+ IFS='
    '
+ SELF_CMD=/usr/local/bin/kubectx
+ KUBECTX=/Users/sod/.kube/kubectx
/usr/local/bin/kubectx: line 250: $@: unbound variable

Running on zsh 5.7.1 (x86_64-apple-darwin19.0)

I grabbed the binary version from the release and that does indeed work for me, so I'll just pop that in my path. If you'd like me to try anything else, I'm happy to assist - but this workaround fixes all my issues so we can close this out if it's a niche edge case / environment-specific issue not affecting anyone else.

ahmetb commented 2 years ago

I assume kubectx is running in bash (despite you launch it from zsh) so I may need your bash version as well. 😇

Sodman commented 2 years ago

Apologies for the delay. Bash version info below:

$ bash --version
GNU bash, version 4.0.0(1)-release (i386-apple-darwin19.4.0)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law