kovidgoyal/kitty · error

Failed to copy data from STDIN pipe to temp file with error:

Error message

Failed to copy data from STDIN pipe to temp file with error: %w

What it means

After creating the spill temp file, remaining STDIN data is copied into it with io.Copy. If that copy fails (mid-stream write/read error), this error is returned. It means the pipe or the temp filesystem failed while transferring large clipboard data.

Source

Thrown at kittens/clipboard/legacy.go:89

	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
	var tempfile *os.File
	if !stdin_is_tty && !opts.GetClipboard {
		// we dont read STDIN when getting clipboard as it makes it hard to use the kitten in contexts where
		// the user does not control STDIN such as being execed from other programs.
		data_src, tempfile, err = preread_stdin()
		if err != nil {

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Verify the upstream pipeline command completes without being killed
  2. Ensure the temp filesystem has space for the full payload
  3. Re-run with a smaller payload to confirm the size threshold is the issue
Defensive patterns

Strategy: retry

Validate before calling

// ensure temp fs has space: check syscall.Statfs on os.TempDir() before the transfer

Try / catch

if err != nil && strings.Contains(err.Error(), "copy data from STDIN") { /* free space / smaller payload, then re-run */ }

Prevention

When it happens

Trigger: Piping >2MB where the writer dies mid-copy (EPIPE) or the temp filesystem fills up during io.Copy.

Common situations: Upstream command killed by a signal mid-pipe; tmpfs disk-full while spilling large clipboard payloads.

Related errors


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