{"record":{"id":"ab7bed00388cd7a4","repo":"stablyai/orca","slug":"command-0-failed-to-set-clipboard","errorCode":null,"errorMessage":"{command[0]} failed to set clipboard","messagePattern":"(.+?) failed to set clipboard","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"native/computer-use-linux/runtime.py","lineNumber":1010,"sourceCode":"            timeout=CLIPBOARD_COMMAND_TIMEOUT_SECONDS,\n        )\n        return\n    for command in ([\"xclip\", \"-selection\", \"clipboard\"], [\"xsel\", \"--clipboard\", \"--input\"]):\n        if not shutil.which(command[0]):\n            continue\n        process = subprocess.Popen(\n            command,\n            stdin=subprocess.PIPE,\n            stdout=subprocess.DEVNULL,\n            stderr=subprocess.DEVNULL,\n            text=True,\n        )\n        if process.stdin is not None:\n            process.stdin.write(value)\n            process.stdin.close()\n        time.sleep(CLIPBOARD_OWNER_SETTLE_SECONDS)\n        if process.poll() not in (None, 0):\n            raise RuntimeError(f\"{command[0]} failed to set clipboard\")\n        return\n    raise RuntimeError(\"paste_text requires wl-copy, xclip, or xsel\")\n\n\ndef set_value(node, value):\n    if node is not None and bool(attempt(node.is_editable_text, False)):\n        editable = attempt(node.get_editable_text_iface)\n        if editable is not None and attempt(lambda: Atspi.EditableText.set_text_contents(editable, str(value)), False):\n            return True\n    value_iface = attempt(node.get_value_iface) if node is not None else None\n    if value_iface is not None:\n        return bool(attempt(lambda: Atspi.Value.set_current_value(value_iface, float(value)), False))\n    return False\n\n\ndef run_operation(operation):\n    tool = operation.get(\"tool\")\n    include_screenshot = not bool(operation.get(\"noScreenshot\"))","sourceCodeStart":992,"sourceCodeEnd":1028,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/native/computer-use-linux/runtime.py#L992-L1028","documentation":"Raised by write_clipboard (runtime.py:1010) when the xclip or xsel subprocess (used to take clipboard ownership) exits with a non-zero / non-None status after being fed the value on stdin. The check runs after a CLIPBOARD_OWNER_SETTLE_SECONDS sleep; command[0] is the program name (xclip or xsel). wl-copy uses a different code path and does not reach this line.","triggerScenarios":"paste_text or write_clipboard is invoked; wl-copy is absent; xclip/xsel is present and started, but exits non-zero — e.g. no X server/clipboard daemon reachable, DISPLAY unset, xsel lost the selection race, or the tool printed an error to its suppressed stderr.","commonSituations":"Running under SSH/headless without a real X server (DISPLAY points at nothing); a broken X selection daemon; xclip present but the X connection died mid-run; stale xclip binary that crashes.","solutions":["Ensure a working X server and DISPLAY (or use wl-copy under a Wayland session with WAYLAND_DISPLAY).","Install wl-copy so write_clipboard takes the wl-copy fast path that does not hit this check.","Diagnose by running `xclip -selection clipboard` manually with a value and checking its exit code and stderr."],"exampleFix":"# before: xclip exits non-zero under headless X\n# after (shell): provide a clipboard-capable session or use wl-copy\nsudo apt install wl-clipboard  # then run under the matching session","handlingStrategy":"fallback","validationCode":"import shutil, os\n\ndef clipboard_writer_ok():\n    if shutil.which(\"wl-copy\"):\n        return True\n    tool = \"xclip\" if shutil.which(\"xclip\") else (\"xsel\" if shutil.which(\"xsel\") else None)\n    if not tool:\n        return False\n    return bool(os.environ.get(\"DISPLAY\") or os.environ.get(\"WAYLAND_DISPLAY\"))","typeGuard":"import shutil, os\n\ndef can_write_clipboard() -> bool:\n    has_tool = any(shutil.which(t) for t in (\"wl-copy\", \"xclip\", \"xsel\"))\n    has_display = bool(os.environ.get(\"DISPLAY\") or os.environ.get(\"WAYLAND_DISPLAY\"))\n    return has_tool and has_display","tryCatchPattern":"try:\n    run_operation(op)\nexcept RuntimeError as e:\n    if \"failed to set clipboard\" in str(e):\n        # fall back to type_text instead of paste\n        op = {\"tool\": \"type_text\", \"text\": text}\n        run_operation(op)\n    else:\n        raise","preventionTips":["Ensure a real X or Wayland display is reachable (DISPLAY/WAYLAND_DISPLAY set).","Prefer wl-copy on Wayland to avoid xclip/xsel exit races.","Keep a type_text fallback for when clipboard writes fail."],"tags":["environment","computer-use","clipboard","x11","python"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}