Why does "kubectl" in a cygwin shell ignore KUBECONFIG, but Go apps using same api work fine?
KARR, DAVID
dk068x@att.com
Sat Jun 28 15:43:47 GMT 2025
Ok, well, I looked at these ideas and eliminated a few and looked at the $HOME problem. I already dealt with this with Eclipse, as the egit plugin gets confused by the Cygwin HOME. As I long ago implemented a little “pathsearch” tool that lets me find the NEXT occurrence of an executable in the PATH, creating that “kubectl” wrapper to override HOME was simple, and it works.
It’s really odd that kubectl works fine if it is just getting the single “config” file, which is in a subdirectory of my Windows HOME, so somehow it still finds that. It only breaks when that file doesn’t exist and it has to read the KUBECONFIG var, which is in Windows format.
The other curious clue is the error message I get when it wasn’t finding the config file, which is:
error: CreateFile C:\cygwin64\home\<userid>\.kube\config: The file cannot be accessed by the system.
That path is my CYGWIN home, where in that directory I have this:
% ls -lt .kube
lrwxrwxrwx 1 <userid> Domain Users 22 Aug 8 2024 .kube -> /c/users/<userid>/.kube//
So the kubectl exe, which is a Windows application, seems like it is interpreting my Cygwin HOME, and the symlink, to determine that the default file doesn’t exist.
Not sure if I’ll ever figure out what’s really happening here, but at least I have a solution. Thanks.
From: Cygwin <cygwin-bounces~dk068x=att.com@cygwin.com> On Behalf Of matthew patton via Cygwin
Sent: Friday, June 27, 2025 11:47 AM
To: cygwin@cygwin.com
Subject: Re: Why does "kubectl" in a cygwin shell ignore KUBECONFIG, but Go apps using same api work fine?
> In my Cygwin home, the ". kube" directory is a symlink to my Windows home what KIND of symlink? If the old cygwin style or the current 'default', it doesn't work or rarely. I've replaced cygwin 'ln' with my own bash function wrapper that
ZjQcmQRYFpfptBannerStart
> In my Cygwin home, the ".kube" directory is a symlink to my Windows home
what KIND of symlink? If the old cygwin style or the current 'default', it doesn't work or rarely. I've replaced cygwin 'ln' with my own bash function wrapper that calls mklink.exe. that way windows tools can do the right thing.
I might also recommend you replace kubectl with a batch/shell file that resets $HOME to $USERPROFILE so you can dispense with trying to be cute.Other gotchas include GOPATH and such if the binary is windows but called within cygwin you gotta make sure you're not using cygwin/linux idioms for path delimiter. It has to be Windows style.
More information about the Cygwin
mailing list