kubectx icon indicating copy to clipboard operation
kubectx copied to clipboard

kubectx and fzf on windows problem

Open sergeypugachov opened this issue 4 years ago • 11 comments

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]

image

sergeypugachov avatar Jul 19 '21 10:07 sergeypugachov

Can you set environment variable DEBUG=1 and see if it prints anything useful? Also does fzf work by itself?

ahmetb avatar Jul 19 '21 19:07 ahmetb

@ahmetb I had the same issue on MacOS. The issue was resolved once I had more than one context in the list.

Tazminia avatar Dec 29 '21 09:12 Tazminia

@ahmetb I had the same issue on windows 11.

v5tech avatar Jan 11 '22 07:01 v5tech

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!

davideLarosa avatar Feb 01 '22 18:02 davideLarosa

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.

davideLarosa avatar Feb 18 '22 09:02 davideLarosa

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.

twobiers avatar Jun 01 '22 12:06 twobiers

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!

upstream-dmahlberg avatar Jan 31 '23 08:01 upstream-dmahlberg

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?

victorsmoliveira avatar Feb 15 '23 14:02 victorsmoliveira

@vsmoliveira How did you get it to work with powershell? Which version fzf or which installer do you use?

upstream-dmahlberg avatar Feb 16 '23 06:02 upstream-dmahlberg

@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

victorsmoliveira avatar Feb 17 '23 01:02 victorsmoliveira

This seems related to #382

mloskot avatar Apr 06 '23 10:04 mloskot