WSL2: Cannot paste image from Windows clipboard (missing PowerShell fallback)
Environment
- OS: Windows 11 + WSL2 (Ubuntu 22.04)
- Terminal: WezTerm
- Claude Code version: 2.1.90
- \
TERM_PROGRAM\: WezTerm - \
WSL_DISTRO_NAME\: Ubuntu-22.04 - \
WSL_INTEROP\: /run/WSL/344443_interop
Problem
Pasting images with \Ctrl+V\ in Claude Code does nothing on WSL2. The clipboard appears empty even after taking a Windows screenshot (Win+Shift+S).
Root Cause (traced through binary)
Claude Code's image paste logic (in \xvK()\) selects clipboard commands by platform:
- macOS → \
osascript\(works, system-native) - Linux → \
xclip -selection clipboard -t TARGETS -o\or \wl-paste -l\ - Windows → \
powershell Get-Clipboard -Format Image\
On WSL2, \process.platform\ returns \"linux"\, so it uses the Linux branch. But WSLg's clipboard bridge only syncs text formats — image data from the Windows clipboard is never passed through to the X11 clipboard. So even with \xclip\ installed, \checkImage\ finds nothing.
Verified:
\\\`bash
After taking a Windows screenshot:
$ xclip -selection clipboard -t TARGETS -o
TIMESTAMP
TARGETS
UTF8_STRING
TEXT
No image/png — WSLg dropped it
\\\`
The PowerShell code to read the Windows clipboard image already exists in the Claude Code binary for the \win32\ branch — it just never runs on WSL2.
Expected Fix
Detect WSL2 (via \WSL_INTEROP\, \WSLENV\, or \WSL_DISTRO_NAME\ env vars) and fall back to \powershell.exe\ when the Linux clipboard check finds no image.
Confirmed that \powershell.exe\ is callable from WSL2:
\\\`bash
$ powershell.exe -NoProfile -Command \
'$img = Get-Clipboard -Format Image; if ($img -ne $null) { "has image" } else { "no image" }'
Returns "no image" only because clipboard was empty at test time — the call itself works
\\\`
Reference Implementation
OpenAI Codex solved the exact same problem in openai/codex#5644:
- Detect WSL via env vars (\
WSL_INTEROP\/ \WSLENV\/ \WSL_DISTRO_NAME\) - On clipboard failure, call \
powershell.exe -NoProfile -Command\with:
\\\powershell\
$img = Get-Clipboard -Format Image
if ($img -ne $null) {
$p = [System.IO.Path]::ChangeExtension([System.IO.Path]::GetTempFileName(), 'png')
$img.Save($p, [System.Drawing.Imaging.ImageFormat]::Png)
Write-Output $p
} else { exit 1 }
\\
- Map the returned Windows path (\
C:\...\) to its WSL mount path (\/mnt/c/...\)
The fix is minimal — the PowerShell command already exists in Claude Code's \win32\ branch. It just needs a WSL detection check to route into it from the Linux path.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗