ahmetb / kubectx

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

kubectx and fzf on windows problem #307

Open sergeypugachov opened 3 years ago

sergeypugachov commented 3 years ago

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

ahmetb commented 3 years ago

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

Tazminia commented 2 years ago

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

v5tech commented 2 years ago

@ahmetb I had the same issue on windows 11.

davideLarosa commented 2 years ago

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 commented 2 years ago

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.

twobiers commented 2 years ago

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.

upstream-dmahlberg commented 1 year ago

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!

victorsmoliveira commented 1 year ago

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?

upstream-dmahlberg commented 1 year ago

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

victorsmoliveira commented 1 year ago

@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

mloskot commented 1 year ago

This seems related to #382