anthropics / anthropics/claude-code

[BUG] WSL/WSLg: image paste fails because wl-paste returns BMP into a .png path

オープン
#89,223 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:tui bug platform:linux platform:wsl
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

### Preflight Checklist

- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code

### What's Wrong?

On WSL2 with WSLg, pasting a Windows screenshot (ctrl+v or alt+v) always answers `No image found in clipboard. Use ctrl+v to paste images.`

**The detection step is not the problem — it succeeds.** `checkImage` falls back from `xclip -t TARGETS` to `wl-paste -l`, which reports `image/bmp`, and that matches the regex.

The failure is the **format**. `saveImage` runs its chain and the winning link is:

```
wl-paste --type image/bmp > /claude_cli_latest_screenshot.png
```

WSLg publishes the Windows clipboard image **only** as `image/bmp`, so the file written to a `.png` path holds a BMP. It is rejected downstream, and the user sees `No image found in clipboard`.

The PowerShell fallback appended for WSL — which would have produced a real PNG — never runs, because the BMP link exited 0 before it was reached.

### What Should Happen?

The screenshot should attach, as it does on other platforms.

Either fix would do:

1. **Convert on read** — transcode to PNG when the winning link produced a BMP.
2. **Reorder for WSL** — try the PowerShell PNG path before the `image/bmp` links when the platform is `wsl`, since it yields a directly usable PNG.

### Error Messages/Logs

```shell
$ wl-paste -l
image/bmp

$ wl-paste --type image/png > /tmp/x 2>/dev/null; echo "exit=$?"
exit=1

$ wl-paste --type image/bmp > /tmp/x; file -b /tmp/x
PC bitmap, Windows 3.x format, 1920 x 1032 x 32

$ xclip -selection clipboard -t TARGETS -o
TIMESTAMP
TARGETS
UTF8_STRING
TEXT

# the data IS available as PNG on the Windows side, just not over Wayland:
$ powershell.exe -NoProfile -Command "...GetDataObject().GetFormats()"
System.Drawing.Bitmap, Bitmap, PNG, CanUploadToCloudClipboard, CanIncludeInClipboardHistory
```

### Steps to Reproduce

1. Run Claude Code inside WSL2 with WSLg, with `wl-clipboard` installed.
2. On the Windows side, take a screenshot with `Win+Shift+S` so it lands on the Windows clipboard.
3. At the Claude Code prompt, press `ctrl+v` (or `alt+v`).
4. `No image found in clipboard. Use ctrl+v to paste images.` appears and nothing is attached.

Confirmation that only the format is at fault — put a real PNG on the Wayland clipboard and paste again:

```
wl-copy --type image/png < some.png
```

Both `ctrl+v` and `alt+v` then attach the image immediately, with no other change.

### Claude Model

Opus

### Is this a regression?

I don't know

### Last Working Version

_No response_

### Claude Code Version

2.1.241 (Claude Code)

### Platform

Anthropic API

### Operating System

Ubuntu/Debian Linux

### Terminal/Shell

Windows Terminal

### Additional Information

**This replaces my original description of the same report, which had the cause wrong.** I first blamed `checkImage` for lacking a `wl-paste` fallback; it has one, the chain is fine, and detection succeeds. The defect is that a BMP ends up in a file named `.png`.

Environment: WSL2 (kernel `6.18.33.2-microsoft-standard-WSL2`), Ubuntu, `wl-clipboard 2.2.1`, `xclip 0.13`, Windows Terminal, WSLg active (`WAYLAND_DISPLAY=wayland-0`, `DISPLAY=:0`).

Feedback ID from the in-app report: `fe517440-cbac-44ee-b945-56e51653bcfe`

Workaround in use: a local `wl-paste` wrapper that serves `image/png` by transcoding the BMP with ffmpeg (~500 ms, against ~1.7 s for the PowerShell path) and advertises `image/png` in `--list-types`. Paste works normally with it in place.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start at the checkImage and saveImage clipboard-handling paths described in the report, then reproduce the WSL2/WSLg case with wl-paste -l and an image/bmp result. Verify the fix by pasting a Windows screenshot and confirming that it attaches successfully as a valid PNG rather than a BMP stored at a .png path.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
linux, powershell
領域
cli, operating-systems
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。