{"record":{"id":"6d11421b481b9b99","repo":"plandex-ai/plandex","slug":"failed-to-create-temporary-file-w","errorCode":null,"errorMessage":"failed to create temporary file: %w","messagePattern":"failed to create temporary file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/upgrade.go","lineNumber":113,"sourceCode":"\t\t}\n\t}\n}\n\nfunc doUpgrade(version string) error {\n\ttag := fmt.Sprintf(\"cli/v%s\", version)\n\tescapedTag := url.QueryEscape(tag)\n\n\tdownloadURL := fmt.Sprintf(\"https://github.com/plandex-ai/plandex/releases/download/%s/plandex_%s_%s_%s.tar.gz\", escapedTag, version, runtime.GOOS, runtime.GOARCH)\n\tresp, err := http.Get(downloadURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to download the update: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// Create a temporary file to save the downloaded archive\n\ttempFile, err := os.CreateTemp(\"\", \"*.tar.gz\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temporary file: %w\", err)\n\t}\n\tdefer os.Remove(tempFile.Name()) // Clean up file afterwards\n\n\t// Copy the response body to the temporary file\n\t_, err = io.Copy(tempFile, resp.Body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to save the downloaded archive: %w\", err)\n\t}\n\n\t_, err = tempFile.Seek(0, 0)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to seek in temporary file: %w\", err)\n\t}\n\n\t// Now, extract the binary from the tempFile\n\tgzr, err := gzip.NewReader(tempFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create gzip reader: %w\", err)","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/upgrade.go#L95-L131","documentation":"After fetching the release archive, doUpgrade creates a temp file with os.CreateTemp to hold the downloaded tar.gz. If the OS refuses to create the file, the error is wrapped as 'failed to create temporary file: %w'. This is an environment/permissions problem on the local filesystem, not a network issue.","triggerScenarios":"os.CreateTemp(\"\", \"*.tar.gz\") fails because TMPDIR points to a non-writable or nonexistent directory, the disk is full, or strict permissions/noexec tmpfs settings block file creation.","commonSituations":"Read-only /tmp (container with read-only rootfs), TMPDIR set to a path the user can't write, disk quota exhausted, SELinux/AppArmor denial.","solutions":["Check TMPDIR points to a writable directory; unset or fix it if wrong.","Free disk space on the temp filesystem (df /tmp).","Set TMPDIR to a writable path, e.g. export TMPDIR=$HOME/tmp.","Check mount options/permissions on /tmp (chmod 1777) or SELinux denials."],"exampleFix":"// before\nexport TMPDIR=/nonexistent\n// after\nexport TMPDIR=$HOME/tmp && mkdir -p $HOME/tmp","handlingStrategy":"validation","validationCode":"tmpDir := os.TempDir()\nfi, err := os.Stat(tmpDir)\nif err != nil || !fi.IsDir() {\n\treturn fmt.Errorf(\"temp dir %s unusable\", tmpDir)\n}\nprobe, err := os.CreateTemp(tmpDir, \".probe\")\nif err != nil {\n\treturn fmt.Errorf(\"temp dir not writable: %w\", err)\n}\nprobe.Close()\nos.Remove(probe.Name())","typeGuard":null,"tryCatchPattern":"tempFile, err := os.CreateTemp(\"\", \"*.tar.gz\")\nif err != nil {\n\treturn fmt.Errorf(\"failed to create temporary file: %w (TMPDIR=%s)\", err, os.TempDir())\n}","preventionTips":["Keep TMPDIR pointing at a writable local directory","Monitor disk space on the temp filesystem","Avoid read-only root filesystems for tools that self-update","Check SELinux/AppArmor denials if /tmp writes fail"],"tags":["filesystem","permissions","go","tmpfile"],"backgroundTag":"temp-file-creation-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}