kn func fails when KUBECONFIG contains multiple colon-separated paths
Describe the bug
kn func commands that require cluster access (e.g., deploy, list, invoke) fail with an ErrInvalidKubeconfig error when the KUBECONFIG environment variable is set to a colon-separated list of paths — which is standard Kubernetes behavior supported by kubectl and client-go.
Expected behavior
kn func should accept a KUBECONFIG value with multiple colon-separated paths (e.g., ~/.kube/config:/other/kubeconfig) the same way kubectl and other Kubernetes tooling does.
Actual behavior
The command fails immediately with an error like:
Error: invalid kubeconfig: kubeconfig file does not exist at path: /home/user/.kube/config:/other/kubeconfig
Possible root cause
validateKubeconfigFile() in pkg/knative/client.go reads the KUBECONFIG env var and passes the entire string directly to os.Stat(), treating it as a single file path:
func validateKubeconfigFile() error {
kubeconfigPath := os.Getenv("KUBECONFIG")
if kubeconfigPath == "" {
return nil
}
if _, err := os.Stat(kubeconfigPath); os.IsNotExist(err) {
return fmt.Errorf("%w: kubeconfig file does not exist at path: %s", fn.ErrInvalidKubeconfig, kubeconfigPath)
}
return nil
}
When KUBECONFIG=/path/a:/path/b, os.Stat("/path/a:/path/b") fails because /path/a:/path/b is not a valid single path.
Steps to reproduce
- Set
KUBECONFIG to multiple paths: export KUBECONFIG=~/.kube/config:/path/to/second/config
- Run any cluster-bound command:
kn func list
- Observe the
ErrInvalidKubeconfig error.
Environment
kn func version: v0.48.3
- OS: macOS 26.4
KUBECONFIG value format: multiple colon-separated paths
kn funcfails whenKUBECONFIGcontains multiple colon-separated pathsDescribe the bug
kn funccommands that require cluster access (e.g.,deploy,list,invoke) fail with anErrInvalidKubeconfigerror when theKUBECONFIGenvironment variable is set to a colon-separated list of paths — which is standard Kubernetes behavior supported bykubectlandclient-go.Expected behavior
kn funcshould accept aKUBECONFIGvalue with multiple colon-separated paths (e.g.,~/.kube/config:/other/kubeconfig) the same waykubectland other Kubernetes tooling does.Actual behavior
The command fails immediately with an error like:
Possible root cause
validateKubeconfigFile()inpkg/knative/client.goreads theKUBECONFIGenv var and passes the entire string directly toos.Stat(), treating it as a single file path:When
KUBECONFIG=/path/a:/path/b,os.Stat("/path/a:/path/b")fails because/path/a:/path/bis not a valid single path.Steps to reproduce
KUBECONFIGto multiple paths:export KUBECONFIG=~/.kube/config:/path/to/second/configkn func listErrInvalidKubeconfigerror.Environment
kn funcversion: v0.48.3KUBECONFIGvalue format: multiple colon-separated paths