Why does "kubectl" in a cygwin shell ignore KUBECONFIG, but Go apps using same api work fine?
Andrey Repin
anrdaemon@yandex.ru
Sun Jun 29 11:39:22 GMT 2025
Greetings, KARR, DAVID!
> 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.
There's no need for it, if you are ready to trade some headache for
convenience.
Just use your profile as your Cygwin $HOME.
> 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//
The question stands, WHAT is that symlink?
>> cmd /C dir .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.
Generally, it is a bad idea to use two tools of different origin for the same
purpose. I suggest you write a simple wrapper to use windows one in Cygwin.
Smth. along the lines of
>> #!/bin/sh
>>>> (
>> _cmd=
>> if [ "1ドル" ] && [ -f "${_cmd:="$( cygpath -aml -- "1ドル" )"}" ]; then
>> shift
>> set -- "$_cmd" "$@"
>> fi
>> unset _cmd
>>>> eval "PATH='/proc/cygdrive/C/Program Files/nodejs:$PATH'" export PATH
>> "/proc/cygdrive/C/Program Files/nodejs/npm.cmd" "$@"
>> )
> Not sure if I’ll ever figure out what’s really happening here, but at least I have a solution. Thanks.
--
With best regards,
Andrey Repin
Sunday, June 29, 2025 14:01:42
Sorry for my terrible english...
More information about the Cygwin
mailing list