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:
chunkis a decoded UTF-8stringinstead of aBuffer(corrupting binary image bytes and causingBuffer.concatto throw
TypeError [ERR_INVALID_ARG_TYPE]).- Because the
dataevent handler throws,stdoutremainsBuffer.alloc(0)(0bytes). - When
wl-paste --type image/pngexits withcode === 0, the promise resolves with the emptyBuffer, the caller skips it
(if (0 === t.length) continue), and all subsequent MIME attempts fail the same way onstderr.
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
- Copy any image (e.g. a PNG screenshot) to the system clipboard on Linux (
wl-copy < image.pngor region screenshot). - Confirm
wl-paste --list-typesincludesimage/png. - Open
cursor-agent(agent) in a terminal and pressCtrl+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