kubectx and fzf on windows problem
I use latest kubectx (0.9.4) and fzf (0.27.2) with powershell 7 on windows 10 (19042.1110).
If i remove fzf from PATH, everything works. With fzf on PATH, kubectx failed with error:
[Command failed: C:\Portable Programs\kubectx.exe]

Can you set environment variable DEBUG=1 and see if it prints anything useful? Also does fzf work by itself?
@ahmetb I had the same issue on MacOS. The issue was resolved once I had more than one context in the list.
@ahmetb I had the same issue on windows 11.
here the same issue with kubectx and kubens. I'm running them on windows 11 using git bash. Does anyone solved it in some way? Thank you!
Hi everyone, after a lot of tests i've got my solution. At the beginning I was placing all my gitbash customizations on a folder under C:\Program Files\shell_addons. In my PATH environment there was just a line adding this folder and, using kubens and kubectx with fzf the command was failing with the same message @sergeypugachov is having. Now i moved the "shell_addons" folder under C:\ and it works. Here my .bashrc settings:
...
#completion
source /etc/bash_completion.d/kubectl
source /c/shell_addons/kubectx/completion/kubens.bash
source /c/shell_addons/kubectx/completion/kubectx.bash
source /c/shell_addons/fzf/functions.sh
source /c/shell_addons/complete-alias/complete_alias
source /c/shell_addons/kube-ps1.sh
#alias complete
complete -F __start_kubectl k
complete -F _kube_contexts kx
complete -F _kube_namespaces ks
#fzf configuration
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
export FZF_DEFAULT_COMMAND="fd --type f"
export FZF_CTRL_T_OPTS="--preview 'bat --style=numbers --color=always --line-range :500 {}'"
export FZF_ALT_C_OPTS="--preview 'tree -C {}'"
...
Hope this can help.
Cheers.
I had this issue too, in my case my SHELL environment variable was pwsh -NoLogo which seems to not work properly with fzf. Changing it to just pwsh without parameter fixed my problem. I tried to do some escaping on the parameter but couldn't make it work otherwise than completely removing it.
I ran into a simliar problem on windows machines and found this blog post: https://medium.com/dataseries/handy-kubernetes-context-namespace-switcher-for-powershell-a432ff8ae7cd
This does not use kubectx / kubens per se, but offers a similar user experience utilizing two short powershell scripts. Hope this helps anyone out there!
I only have this problem when using Git Bash terminal, powershell works fine. However I really wanted to use it with Git Bash. Does anyone have a fix?
@vsmoliveira How did you get it to work with powershell? Which version fzf or which installer do you use?
@upstream-dmahlberg Installed via chocolatey running choco install fzf.
The installed fzf version is 0.37.0 (2023012) kubectx/kubens version is 0.9.4
This seems related to #382