kubectl diff on windows returns an error: executable file not found in PATH

Viewed 3173

I have a problem using Kubectl on Windows:

C:\> kubectl diff -f app.yml
error: executable file not found in %PATH%

Kubernetes is installed with the Docker Desktop. The same error comes independent of the file, I'm using as an argument (even if the .yml file doesn't contain anything).

Version:

C:\> kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:36:53Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.6", GitCommit:"96fac5cd13a5dc064f7d9f4f23030a6aeface6cc", GitTreeState:"clean", BuildDate:"2019-08-19T11:05:16Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
6 Answers

After installing DiffUtils for Windows on my local machine and restarting the machine everything works.

Try to install using choco - no need to restart Windows.

choco install diffutils

The kubectl diff command uses the Unix diff program under the hood. Presumably you don't have this installed. You can probably install it through WSL or your other favorite way to get Unix-y programs.

Having had essentially the same issue as OP the solution for me required some extra steps: installing DiffUtils for Windows as mentioned, and then mapping the bin folder (by default at C:\Program Files (x86)\GnuWin32\bin) in my Win10 PATH variable.

I'm assuming the installer for DiffUtils was supposed to map it, but for whatever reason it failed to do so, resulting in me having to do this manually.

If you already have a preferred diff tool installed, set $Env:KUBECTL_EXTERNAL_DIFF. For example:

$Env:KUBECTL_EXTERNAL_DIFF="C:\Progra~1\WinMerge\WinMergeU.exe"

I got the same error. I had git bash installed on my Windows 10 machine. So tried and it worked. So as @coderanger mentioned, it uses UNIX diff program under the hood, git bash works

Related