{"record":{"id":"cbb29ea397d51398","repo":"kovidgoyal/kitty","slug":"failed-to-create-a-temporary-from-stdin-pipe-with","errorCode":null,"errorMessage":"Failed to create a temporary from STDIN pipe with error: %w","messagePattern":"Failed to create a temporary from STDIN pipe with error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/clipboard/legacy.go","lineNumber":83,"sourceCode":"}\n\nfunc preread_stdin() (data_src io.Reader, tempfile *os.File, err error) {\n\t// we pre-read STDIN because otherwise if the output of a command is being piped in\n\t// and that command itself transmits on the tty we will break. For example\n\t// kitten @ ls | kitten clipboard\n\tvar stdin_data []byte\n\tstdin_data, err = read_all_with_max_size(os.Stdin, 2*1024*1024)\n\tif err == nil {\n\t\tos.Stdin.Close()\n\t} else if err != ErrTooMuchPipedData {\n\t\tos.Stdin.Close()\n\t\terr = fmt.Errorf(\"Failed to read from STDIN pipe with error: %w\", err)\n\t\treturn\n\t}\n\tif err == ErrTooMuchPipedData {\n\t\ttempfile, err = utils.CreateAnonymousTemp(\"\")\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"Failed to create a temporary from STDIN pipe with error: %w\", err)\n\t\t}\n\t\ttempfile.Write(stdin_data)\n\t\t_, err = io.Copy(tempfile, os.Stdin)\n\t\tos.Stdin.Close()\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"Failed to copy data from STDIN pipe to temp file with error: %w\", err)\n\t\t}\n\t\ttempfile.Seek(0, io.SeekStart)\n\t\tdata_src = tempfile\n\t} else if stdin_data != nil {\n\t\tdata_src = bytes.NewBuffer(stdin_data)\n\t}\n\treturn\n}\n\nfunc run_plain_text_loop(opts *Options) (err error) {\n\tstdin_is_tty := tty.IsTerminal(os.Stdin.Fd())\n\tvar data_src io.Reader","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/clipboard/legacy.go#L65-L101","documentation":"When piped clipboard data exceeds 2MB, the kitten spills it to an anonymous temp file. If creating that temp file fails, this error is returned. The temp file creation uses unlinked anonymous files, which can fail on filesystems or containers that disallow them.","triggerScenarios":"Piping more than 2MB into the clipboard kitten while utils.CreateAnonymousTemp fails — e.g. TMPDIR pointing to a read-only filesystem, tmpfs full, or a container with /tmp mounted noexec/readonly.","commonSituations":"Docker/container runs with a broken or full /tmp, disk exhaustion, TMPDIR misconfigured.","solutions":["Free space or repoint TMPDIR to a writable location: TMPDIR=/var/tmp kitten +kitten clipboard ...","Reduce piped data below 2MB to avoid the spill path entirely","Check disk space with df -h /tmp"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// check temp dir writability before piping >2MB\nf, err := os.CreateTemp(os.TempDir(), \"\")\nif err != nil { /* fail fast with clear message */ }\nf.Close(); os.Remove(f.Name())","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"temporary from STDIN\") { /* set TMPDIR to a writable dir and retry */ }","preventionTips":["Keep TMPDIR on a writable filesystem with free space","Avoid piping multi-MB payloads unless needed"],"tags":["kitty","clipboard","temp-file","disk-full"],"backgroundTag":"temp-file-creation-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}