Skip to content

tui: WSL image paste fails with X11 clipboard errors after upgrading to V2 #58466

Closed as duplicate

Description

@Gabb1995

Summary

Pasting clipboard images in the OpenCode TUI under Windows Terminal and Ubuntu on WSL2 fails with X11 clipboard errors. This worked before upgrading to OpenCode V2; the current installed version is 2.1.3.

Environment

  • opencode version: 2.1.3
  • OS: Ubuntu 24.04.2 LTS under WSL2; Linux 5.15.167.4-microsoft-standard-WSL2 x86_64
  • Terminal: Windows Terminal; TERM=xterm-256color; WT_SESSION present
  • Shell: /usr/bin/zsh
  • Install/channel: Installed binary at ~/.opencode/bin/opencode; latest channel reported by runtime diagnostics
  • Active plugins: Local UUID plugin (./plugins/uuid/plugin.js); not tested with the plugin disabled
  • Display environment: DISPLAY=:0 and WAYLAND_DISPLAY=wayland-0

Reproduction

  1. Run OpenCode V2 in Ubuntu under WSL2 using Windows Terminal.
  2. Copy an image to the clipboard.
  3. Attempt to paste the image into the TUI prompt using Ctrl+V or Ctrl+Shift+V.

The exact image-copying application and the last working OpenCode version have not yet been identified.

Expected Behavior

The clipboard image is attached to the prompt, as it was before upgrading to V2.

Actual Behavior

Image paste fails with the following errors reported by the user across attempts:

failed to request X11 clipboard conversion
X11 clipboard output flush failed

Both Ctrl+V and Ctrl+Shift+V trigger the failure.

Additional Context

Possibly related to #55639 and #49895. However, this environment does not match the missing-Wayland-symbol cause described in #55639:

  • Ubuntu is 24.04.2 LTS, not 20.04.
  • libwayland-client.so.0 was successfully loaded using Python ctypes.
  • wl_proxy_marshal_array_flags is available in that library.
  • xclip, xsel, and wl-paste are not installed.

The root cause has not been established. These details were collected from the affected environment; the clipboard failure itself has not been independently reproduced by the assistant. No package installation or configuration changes were made during diagnostics.

Activity

  1. opencode-agent commented on Oct 23, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed diagnostics! I think this is a duplicate of #49895, which tracks clipboard image paste failing on WSL2 with Windows Terminal in OpenCode v2 (it worked in 1.x).

    Possible duplicates and related issues, ordered from most to least likely:

    Until a fix lands, these workarounds from #49895 may help:

    • Run export WAYLAND_DISPLAY=/mnt/wslg/runtime-dir/wayland-0 before starting opencode, so the Wayland clipboard is found even if XDG_RUNTIME_DIR doesn't point to WSLg's runtime dir.
    • Update WSL with wsl --update. Newer WSLg versions fixed image paste for some people.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. Gabb1995 commented on Oct 23, 2026

    @Gabb1995
    Author

    Confirmed: launching with the suggested absolute Wayland socket path restores clipboard image paste:

    WAYLAND_DISPLAY=/mnt/wslg/runtime-dir/wayland-0 opencode

    On this affected environment, /mnt/wslg/runtime-dir/wayland-0 exists and is a socket, while /run/user/1000/wayland-0 does not exist. Before the workaround, XDG_RUNTIME_DIR=/run/user/1000/ and WAYLAND_DISPLAY=wayland-0.

    The user tested the command and confirmed image paste works. No WSL update or clipboard package installation was required. This is Ubuntu 24.04.2 LTS with OpenCode 2.1.3; libwayland-client.so.0 loads and exports wl_proxy_marshal_array_flags.

    Thanks for the workaround! Happy for this to be tracked under #49895.

  3. opencode-agent commented on Oct 24, 2026

    @opencode-agent
    Contributor

    We haven't heard back, so I'm closing this as a duplicate of #49895. That issue tracks clipboard image paste failing on WSL2 with Windows Terminal in OpenCode v2, and PR #57470 proposes a fix: read the Windows clipboard through powershell.exe when the native clipboard read fails on WSL. Please follow #49895 for updates.

    Until the fix lands, two workarounds from that thread may help:

    • Run export WAYLAND_DISPLAY=/mnt/wslg/runtime-dir/wayland-0 before starting opencode, so it uses the Wayland clipboard instead of falling back to X11.
    • Update WSL with wsl --update.

    If your problem turns out to be different, reply here and we can reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions