{"record":{"id":"cbfcd2bb74f63076","repo":"ahmetb/kubectx","slug":"home-or-userprofile-environment-variable-not-set-cbfcd2","errorCode":null,"errorMessage":"HOME or USERPROFILE environment variable not set","messagePattern":"HOME or USERPROFILE environment variable not set","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/kubeconfig/kubeconfigloader.go","lineNumber":82,"sourceCode":"\tif err := kf.Truncate(0); err != nil {\n\t\treturn fmt.Errorf(\"failed to truncate file: %w\", err)\n\t}\n\tif _, err := kf.Seek(0, 0); err != nil {\n\t\treturn fmt.Errorf(\"failed to seek in file: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc kubeconfigPaths() ([]string, error) {\n\t// KUBECONFIG env var\n\tif v := os.Getenv(\"KUBECONFIG\"); v != \"\" {\n\t\treturn filepath.SplitList(v), nil\n\t}\n\n\t// default path\n\thome := cmdutil.HomeDir()\n\tif home == \"\" {\n\t\treturn nil, errors.New(\"HOME or USERPROFILE environment variable not set\")\n\t}\n\treturn []string{filepath.Join(home, \".kube\", \"config\")}, nil\n}\n","sourceCodeStart":64,"sourceCodeEnd":86,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/internal/kubeconfig/kubeconfigloader.go#L64-L86","documentation":"Guard error in kubeconfigPaths: the KUBECONFIG env var is unset and cmdutil.HomeDir() returned an empty string because neither HOME nor USERPROFILE is set, so the default kubeconfig path (~/.kube/config) cannot be derived. The loader has no files to open.","triggerScenarios":"Thrown at internal/kubeconfig/kubeconfigloader.go:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set KUBECONFIG to the kubeconfig path explicitly","Set the HOME (or USERPROFILE) environment variable so ~/.kube/config can be resolved"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"12ad6fb22e8c546ee2b54e7de38aa51c906832f7","analyzedAt":"2026-09-02T12:23:10.107Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}