WSL2: Cannot paste image from Windows clipboard (missing PowerShell fallback)

Status Fixed / completed
Reported on v2.1.90
Maintainer reply None cached
Activity 8 comments · opened Apr 2, 2026 · closed May 7, 2026

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:

  1. Detect WSL via env vars (\WSL_INTEROP\ / \WSLENV\ / \WSL_DISTRO_NAME\)
  2. 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 }
\
\\

  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.

View original on GitHub ↗

7 Comments

hqhq1025 · 4 months ago

If you're developing from macOS and SSH into a WSL2 environment, clipaste v2.1.0 can help.

It runs a local HTTP server + SSH tunnel to bridge your macOS clipboard to the remote:

# On macOS
brew install hqhq1025/clipaste/clipaste && brew services start clipaste
clipaste ssh-setup user@your-wsl-host

After setup, Ctrl+V in remote Claude Code fetches screenshots through the tunnel. No PowerShell or Windows clipboard access needed — it bypasses the Windows clipboard entirely by serving images from your Mac.

phoenixf · 4 months ago

+1 — this isn't a minor inconvenience, it breaks the core CLI UX.

Pasting screenshots is table-stakes in ChatGPT, Cursor, and Claude Desktop. Having to Win+Shift+S → save to disk → drag/type the path turns a 1-second action into a multi-step chore that actively pushes me back to the GUI clients for any visual debugging task (UI bugs, error screenshots, design reviews, chart analysis).

The whole point of a terminal-native agent is fluid, low-friction interaction. Image paste is the single biggest friction point on WSL2 right now.

The referenced fix (Codex PR openai/codex#5644) is ~30 lines and already proven in production. The PowerShell branch already exists in the Claude Code binary — it just needs a WSL detection check to route into it from the Linux path.

Please prioritize.

jcardama · 4 months ago

Hitting this on Claude Code 2.1.119 / WSL2 Ubuntu 24.04 / Windows Terminal.

Confirm: Ctrl+V with an image in the Windows clipboard does nothing in the prompt. WSLg surfaces text fine but image MIME types aren't reliably exposed to wl-paste / xclip, so installing those doesn't help on its own.

Working PowerShell-based workaround that doesn't need any apt installs (round-trips via base64 to avoid UNC-path escaping issues):

#!/usr/bin/env bash
# clip-image — pull the Windows clipboard image into a temp PNG and print its WSL path.
# Usage:
#   clip-image                  # → /tmp/clip-<ts>.png on success, exit 1 if no image
#   clip-image --keep-name foo  # → /tmp/foo.png (overwrites)

set -euo pipefail

name=""
if [[ "${1:-}" == "--keep-name" ]] && [[ -n "${2:-}" ]]; then
  name="$2"
fi

if [[ -z "$name" ]]; then
  out="/tmp/clip-$(date +%Y%m%d-%H%M%S-%N).png"
else
  out="/tmp/${name}.png"
fi

set +e
b64=$(powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "
\$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
\$img = [System.Windows.Forms.Clipboard]::GetImage()
if (\$img -eq \$null) { exit 2 }
\$ms = New-Object System.IO.MemoryStream
\$img.Save(\$ms, [System.Drawing.Imaging.ImageFormat]::Png)
[Convert]::ToBase64String(\$ms.ToArray())
" 2>/dev/null | tr -d '\r\n')
set -e

if [[ -z "$b64" ]]; then
  echo "no image in Windows clipboard" >&2
  exit 1
fi

echo "$b64" | base64 -d > "$out"
[[ -s "$out" ]] || { echo "decode produced empty file" >&2; rm -f "$out"; exit 1; }
echo "$out"

Drop it in ~/bin, add ~/bin to PATH, and either run clip-image manually before referencing the screenshot, or have the agent do it via a CLAUDE.md note like:

If the user references "the screenshot I just copied" but no path is given, run \clip-image\ — it dumps the Windows clipboard PNG to /tmp and prints the path. Read that path.

Native Ctrl+V → image attach in the prompt would still be the right fix (matches macOS / Windows-native behavior), but this unblocks the workflow in the meantime.

silviucercel · 3 months ago

issue still reproducing as of today 16/04/2026 - Claude Code version 2.1.143

elfatherbrown · 3 months ago

Still down for me in 2.1.145 windows 11 winterm.

luodaozhang · 3 months ago

The problem still exists.

davingreen · 2 months ago

Same issue -- just migrated from Copilot extension and this makes it feel like a huge step backwards in productivity. Please fix soon!

Showing cached comments. Read the full discussion on GitHub ↗