codex icon indicating copy to clipboard operation
codex copied to clipboard

Image paste fails with 'no image on clipboard' despite screenshot copy

Open aronweiler opened this issue 5 months ago • 9 comments

What happened?

Pasting a screenshot/image into Codex repeatedly failed. The UI reported that no image was available on the clipboard, even though the user was attempting to paste a screenshot for debugging.

Observed error, repeated several times:

Failed to paste image: no image on clipboard: The clipboard contents were not available in the requested format or the clipboard is empty.

This blocked a normal debugging flow where the user needed to share a screenshot of Google Play Console.

Expected behavior

Codex should accept a copied screenshot/image from the clipboard, or provide a clearer fallback path when the clipboard content cannot be read.

At minimum, the error should distinguish between:

  • the OS clipboard actually being empty
  • the clipboard containing an image in an unsupported format
  • the Codex client failing to access the clipboard image
  • WSL/Windows clipboard interop limitations

Environment

  • Codex CLI: codex-cli 0.142.2
  • OS/session: WSL2 on Windows
  • Kernel: Linux BigFatty 6.18.33.1-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Fri Jun 5 01:12:21 UTC 2026 x86_64 GNU/Linux
  • Workspace path: /mnt/d/repos/fountainrank

Additional context

As a workaround, I tried to pull the image from the Windows clipboard through WSL with PowerShell, but Windows executable interop was not working in this session:

/bin/bash: line 1: /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe: cannot execute binary file: Exec format error

That workaround failure is separate, but it made the missing image-paste support more disruptive because there was no usable in-chat path to attach the screenshot.

Repro steps

  1. Copy a screenshot/image to the clipboard.
  2. Attempt to paste it into Codex chat.
  3. Observe the paste failure:
Failed to paste image: no image on clipboard: The clipboard contents were not available in the requested format or the clipboard is empty.

aronweiler avatar Jun 26 '26 22:06 aronweiler

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #29580

Powered by Codex Action

github-actions[bot] avatar Jun 26 '26 22:06 github-actions[bot]

Additional clarification from the affected session: the core failure is that the user cannot paste an image into Codex at all.

The user repeatedly attempted to paste a screenshot for debugging, and Codex rejected it with:

Failed to paste image: no image on clipboard: The clipboard contents were not available in the requested format or the clipboard is empty.

This is not just a confusing error message. It blocks the basic workflow of sharing a screenshot with Codex when the UI being debugged cannot be described reliably in text.

aronweiler avatar Jun 26 '26 22:06 aronweiler

Severity clarification: this is blocking active work.

Impact:

  • The user cannot paste screenshots/images into Codex at all.
  • Screenshot-based debugging is unusable when the UI state cannot be described reliably in text.
  • The repeated clipboard error gives no actionable recovery path.
  • In this session, the failure directly blocked debugging a Google Play Console release issue.

This should be treated as an imperative workflow blocker, not a cosmetic clipboard-message bug.

aronweiler avatar Jun 26 '26 22:06 aronweiler

I pushed a focused improvement for the WSL failure mode described here:

https://github.com/openai/codex/compare/main...Nicolas0315:codex/wsl-image-paste-fallback-error?expand=1

Commit: 6fa8c1aae5118f2427261b4380211b56f2ed5504

What changed:

  • The WSL image-paste path no longer discards Windows/PowerShell fallback failures and falls back to the original no image on clipboard message.
  • If native clipboard read fails and the WSL fallback also fails, the UI now reports both the native clipboard error and the Windows clipboard fallback error.
  • PowerShell fallback attempts now aggregate failures from powershell.exe, pwsh, and powershell, including execution errors like WSL interop/Exec format error, non-zero status, empty output, unsupported returned paths, or unreadable generated PNGs.
  • Added focused tests for the user-visible WSL fallback error and command-failure aggregation.

Validation:

  • Local Windows rtx4090: just fmt, git diff --check, cargo check -p codex-tui, cargo test -p codex-tui wsl_clipboard_fallback_error_display_preserves_both_contexts, and cargo test -p codex-tui clipboard_paste passed.
  • Local WSL Linux cfg test was attempted, but this WSL environment has no Rust toolchain installed (cargo: command not found).
  • cyberagent-mac-m5max over SSH: exact commit checkout, git diff --check, cargo test -p codex-tui clipboard_paste, and cargo check -p codex-tui passed.
  • nicolas2025 over SSH: exact commit checkout, git diff --check, cargo test -p codex-tui clipboard_paste, and cargo check -p codex-tui passed; no lingering cargo/rustc/link processes.
  • nicolas-macbook-pro over SSH: exact commit checkout and git diff --check passed; no Rust toolchain installed there.
  • rtx5060ti over SSH: exact commit checkout and git diff --check passed; cargo remains blocked by the host's existing linker setup (link.exe rejects MSVC-style arguments), with no lingering cargo/rustc/link processes afterward.

Nicolas0315 avatar Jun 26 '26 22:06 Nicolas0315

Thanks for tracking this. We have validated a Windows-native workaround and believe the remaining failure is at the clipboard/WSL bridge, not image transport.

The current clipboard path can involve native clipboard read, clipboard file-list/image data, and a WSL-to-Windows fallback. When screenshot producers populate the clipboard asynchronously, or when WSL cannot execute powershell.exe, these independent failures can collapse into no image on clipboard.

Suggested fallback hardening:

  1. Add a bounded retry (for example, up to 300-500 ms) for transient clipboard population races.
  2. Preserve both clipboard file-list and image-data paths.
  3. In WSL, try available Windows helpers deterministically and aggregate native plus fallback errors, distinguishing empty clipboard, unsupported format, access failure, and interop/Exec format error.
  4. If the bridge succeeds, write a temporary PNG and pass its path through the existing -i/--image <FILE> flow.
  5. Add Windows-native and WSL integration coverage.

We also validated a lightweight Windows-native clipboard-to-file adapter (Explorer context action -> local agent -> PNG path). It avoids requiring WSL to invoke a Windows executable and uses the existing image-file contract. In local smoke tests it stayed at about 8.5 MiB RSS and 0% idle CPU, with about 541 ms median end-to-end save time over three runs. This is intended as a reference workaround, not a replacement for native paste.

The implementation in codex-rs/tui/src/clipboard_paste.rs already has a WSL fallback, so improving failure classification and making the bridge independent of WSL executable invocation may address the remaining Windows/WSL cases.

DOIT-Ben avatar Aug 31 '26 06:08 DOIT-Ben

Additional WSL reproduction: On Windows, I use Zed to open a project hosted in WSL and run Codex CLI from its WSL terminal. Pasting an image into Codex does not work. I also opened Windows PowerShell directly, ran wsl, and launched Codex CLI in the WSL environment; image pasting still failed there. This reproduces outside Zed, so it does not appear specific to Zed terminal integration and may involve the WSL/Windows clipboard bridge or Codex CLI clipboard fallback. I have not captured the exact Codex CLI version, shortcut used, or error text.

ry4nyu avatar Oct 17 '26 11:10 ry4nyu

Ran into the same clipboard bridge failure on WSL a while back. The --image flag sidesteps it completely since it reads the file directly instead of going through the Windows to WSL clipboard interop, and it's the only method that works inside a script anyway. Might be worth pinning as the documented workaround until the bridge itself gets fixed.

bickov avatar Nov 02 '26 06:11 bickov

+1 that this is a real workflow blocker. One thing that's been reliable for me under WSL2: don't use the clipboard at all. Drag the image file into the Windows Terminal WSL tab, which drops in a /mnt/... path Codex can read, or pass it with -i.

I built a small shelf app partly for this, Hopshot (https://hopshot.xyz, disclosure: I'm the dev). Screenshots stay on a shelf so there's always a real file to drag in. DOIT-Ben's adapter above is a good free option if you'd rather script it.

Mynk96 avatar Nov 17 '26 14:11 Mynk96

(response from codex)

To attach the screenshot in your current chat, save it as a PNG on Windows, then use your terminal’s text-paste command to paste the full WSL path into the Codex prompt. For example, if you saved it to D:\screenshots\example.png, paste /mnt/d/screenshots/example.png on its own. Codex should show an image attachment before you send the message. For a new chat, you can also run codex -i /mnt/d/screenshots/example.png.

I closed this as a duplicate of #7599 because both reports describe screenshot paste failing when WSL can’t launch Windows PowerShell. That issue was closed as not planned. The paste failure remains unresolved.

Codex first tries the Linux clipboard, then falls back to PowerShell to read the Windows clipboard. Your Exec format error shows that WSL couldn’t launch powershell.exe during your manual check. If the same thing happened during paste, Codex would show only the Linux clipboard error. That message doesn’t tell us whether the Windows clipboard contained an image.

CLI 0.172.0 still discards the fallback error. Codex should report when PowerShell can’t start and suggest pasting the saved image’s path.

etraut-openai avatar Nov 24 '26 02:11 etraut-openai