kovidgoyal/kitty · error

Failed to create a temporary from STDIN pipe with error: %w

Error message

Failed to create a temporary from STDIN pipe with error: %w

What it means

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.

Source

Thrown at kittens/clipboard/legacy.go:83

}

func preread_stdin() (data_src io.Reader, tempfile *os.File, err error) {
	// we pre-read STDIN because otherwise if the output of a command is being piped in
	// and that command itself transmits on the tty we will break. For example
	// kitten @ ls | kitten clipboard
	var stdin_data []byte
	stdin_data, err = read_all_with_max_size(os.Stdin, 2*1024*1024)
	if err == nil {
		os.Stdin.Close()
	} else if err != ErrTooMuchPipedData {
		os.Stdin.Close()
		err = fmt.Errorf("Failed to read from STDIN pipe with error: %w", err)
		return
	}
	if err == ErrTooMuchPipedData {
		tempfile, err = utils.CreateAnonymousTemp("")
		if err != nil {
			return nil, nil, fmt.Errorf("Failed to create a temporary from STDIN pipe with error: %w", err)
		}
		tempfile.Write(stdin_data)
		_, err = io.Copy(tempfile, os.Stdin)
		os.Stdin.Close()
		if err != nil {
			return nil, nil, fmt.Errorf("Failed to copy data from STDIN pipe to temp file with error: %w", err)
		}
		tempfile.Seek(0, io.SeekStart)
		data_src = tempfile
	} else if stdin_data != nil {
		data_src = bytes.NewBuffer(stdin_data)
	}
	return
}

func run_plain_text_loop(opts *Options) (err error) {
	stdin_is_tty := tty.IsTerminal(os.Stdin.Fd())
	var data_src io.Reader

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Free space or repoint TMPDIR to a writable location: TMPDIR=/var/tmp kitten +kitten clipboard ...
  2. Reduce piped data below 2MB to avoid the spill path entirely
  3. Check disk space with df -h /tmp
Defensive patterns

Strategy: fallback

Validate before calling

// check temp dir writability before piping >2MB
f, err := os.CreateTemp(os.TempDir(), "")
if err != nil { /* fail fast with clear message */ }
f.Close(); os.Remove(f.Name())

Try / catch

if err != nil && strings.Contains(err.Error(), "temporary from STDIN") { /* set TMPDIR to a writable dir and retry */ }

Prevention

When it happens

Trigger: 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.

Common situations: Docker/container runs with a broken or full /tmp, disk exhaustion, TMPDIR misconfigured.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/cbb29ea397d51398. Report an issue: GitHub.