{"record":{"id":"0c08090837ab4f8f","repo":"ahmetb/kubectx","slug":"failed-to-create-temp-kubeconfig-file-w-0c0809","errorCode":null,"errorMessage":"failed to create temp kubeconfig file: %w","messagePattern":"failed to create temp kubeconfig file: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/shell_session.go","lineNumber":82,"sourceCode":"\t\treturn fmt.Errorf(\"failed to extract kubeconfig for context: %w\", err)\n\t}\n\n\t// Optionally transform the kubeconfig (e.g. rewrite for readonly proxy).\n\tvar cleanup func()\n\tif s.transformKubeconfig != nil {\n\t\tdata, cleanup, err = s.transformKubeconfig(data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif cleanup != nil {\n\t\t\tdefer cleanup()\n\t\t}\n\t}\n\n\t// Write kubeconfig to temp file.\n\ttmpFile, err := os.CreateTemp(\"\", \"kubectx-shell-*.yaml\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temp kubeconfig file: %w\", err)\n\t}\n\ttmpPath := tmpFile.Name()\n\tdefer os.Remove(tmpPath)\n\n\tif _, err := tmpFile.Write(data); err != nil {\n\t\ttmpFile.Close()\n\t\treturn fmt.Errorf(\"failed to write temp kubeconfig: %w\", err)\n\t}\n\ttmpFile.Close()\n\n\t// Print entry message.\n\ts.printEntry(stderr, s.target)\n\n\t// Detect and start shell.\n\tshellBin := detectShell()\n\tcmd := exec.Command(shellBin)\n\tcmd.Stdin = os.Stdin\n\tcmd.Stdout = os.Stdout","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/shell_session.go#L64-L100","documentation":"Returned by run when os.CreateTemp fails to create a temporary file for the per-context kubeconfig extracted earlier in the session setup. This happens when the OS cannot provide a temp file — typically a full/writable-missing TMPDIR, permission problems, or resource exhaustion — meaning the isolated shell session cannot be started, so the whole shell-session operation aborts with this wrapped error.","triggerScenarios":"Thrown at cmd/kubectx/shell_session.go:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check TMPDIR is writable and has free space (df -h /tmp)","Set TMPDIR to a writable directory and retry","Check for inode exhaustion if disk space looks fine"],"exampleFix":null,"handlingStrategy":"try-catch","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"}