`cursor-agent` CLI: Linux clipboard image paste (`Ctrl+V`) fails with `ERR_INVALID_ARG_TYPE` because `execFile` defaults `encoding` to `'utf8'`

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

Pasting an image from the clipboard with Ctrl+V in the interactive cursor-agent TUI always fails silently on Linux
(ctrl-v-clipboard-image-miss), even when wl-paste --type image/png or xclip -selection clipboard -t image/png -o succeeds
and returns valid image bytes.

Actual Behavior

Nothing is attached in the prompt. The session debug log (/tmp/cursor-agent-logs-*/session-*.log) records an
uncaughtException on every stdout chunk followed by ctrl-v-clipboard-image-miss:

uncaughtException: The "list[1]" argument must be an instance of Buffer or Uint8Array. Received type string
('PNG\r\n\u001a\n\u0000\u0000\u0000\rIHDR...')
TypeError [ERR_INVALID_ARG_TYPE]: The "list[1]" argument must be an instance of Buffer or Uint8Array. Received type string

Root Cause

In ./src/utils/clipboard.ts (bundled in 1623.index.js), the helper that runs wl-paste / xclip uses node:child_process
execFile without specifying encoding: "buffer", and then concatenates stdout and stderr chunks with Buffer.concat:

const child = execFile(file, Array.from(args), { timeout: timeoutMs, maxBuffer: 52428800 });
let stdout = Buffer.alloc(0), stderr = Buffer.alloc(0);
child.stdout?.on("data", (chunk) => {
  stdout = Buffer.concat([stdout, chunk]);
});
child.stderr?.on("data", (chunk) => {
  stderr = Buffer.concat([stderr, chunk]);
});

Unlike child_process.spawn(), Node’s child_process.execFile() sets options.encoding = "utf8" by default, which calls
stream.setEncoding("utf8") on child.stdout and child.stderr. As a result:

  1. chunk is a decoded UTF-8 string instead of a Buffer (corrupting binary image bytes and causing Buffer.concat to throw
    TypeError [ERR_INVALID_ARG_TYPE]).
  2. Because the data event handler throws, stdout remains Buffer.alloc(0) (0 bytes).
  3. When wl-paste --type image/png exits with code === 0, the promise resolves with the empty Buffer, the caller skips it
    (if (0 === t.length) continue), and all subsequent MIME attempts fail the same way on stderr.

Suggested Fix

Pass encoding: "buffer" to execFile (or use spawn instead of execFile):

const child = execFile(file, Array.from(args), {
  timeout: timeoutMs,
  maxBuffer: 52428800,
  encoding: "buffer",
});

Steps to Reproduce

  1. Copy any image (e.g. a PNG screenshot) to the system clipboard on Linux (wl-copy < image.png or region screenshot).
  2. Confirm wl-paste --list-types includes image/png.
  3. Open cursor-agent (agent) in a terminal and press Ctrl+V.

Expected Behavior

ctrl+v inserts the image from clipboard

Operating System

Linux

Version Information

Environment

  • Cursor Agent CLI version: 2026.10.22-27dcf5f
  • OS: Linux (Arch Linux, Wayland / X11)
  • Clipboard tools: wl-paste (wl-clipboard) / xclip

Additional Information

I let Gemini 4 Argon patch this locally in the cursor-agent JS files and that worked.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Thanks for flagging this @Sven_1! The team is aware of the issue, which was also reported here. Some users have temporarily downgraded.