minikube: windows MK_WRONG_BINARY_WSL even when not in powershell

The offending function below is incorrectly assuming that if WSLENV has a non-empty value, that the shell is an WSL shell. According to this post, this environment variable is used for sharing variables into new WSL sessions, and is set within Windows too.

https://github.com/kubernetes/minikube/blob/51ec098b056e379d42ed8a9aae3d530309fe508d/pkg/minikube/driver/driver.go#L174-L176

Steps to reproduce the issue:

  1. Ensure the WSLENV environment variable has a non-empty value. Mine is WT_SESSION::WT_PROFILE_ID
  2. Run minikube from a regular Windows cmd.exe shell
  3. Observe the incorrect output
> minikube docker-env

❌  Exiting due to MK_WRONG_BINARY_WSL: You are trying to run windows .exe binary inside WSL, for better integration please use Linux binary instead (Download at https://minikube.sigs.k8s.io/docs/start/.). Otherwise if you still want to do this, you can do it using --force

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 24 (14 by maintainers)

Most upvoted comments

Just came here to say I’m getting the error too. Using the Windows executable inside PowerShell. Also it recommends trying to use --force buuuuut

~
➜  minikube version --force
Error: unknown flag: --force
See 'minikube version --help' for usage.
~
➜  minikube --force version
Error: unknown flag: --force
See 'minikube --help' for usage.

Tested the above PR in Windows Terminal before and after and fixed the issue on my machine.

After looking at the envs being preserved through WSLENV, I realised this is exclusive to cmd.exe sessions spawned by Windows Terminal (WT_SESSION and WT_PROFILE_ID are env vars provided by Windows Terminal). It actually behaves correctly when run from a regular cmd.exe (and powershell) session.

I think it’s improper behaviour to check for WSLENV being set, as this is not indicative of the shell being run under WSL, but rather which environment variables from Windows should be carried over into new WSL sessions.

@trixnz meanwhile I wonder does --force override the error for you ? minikube docker-env --force . ?

No, it errors that --force is an unknown flag.

> minikube status --force
Error: unknown flag: --force
See 'minikube status --help' for usage.