-
Couldn't load subscription status.
- Fork 6k
Fix: Image paste/upload does not work under WSL (Windows Subsystem for Linux) #5644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Hi maintainers 👋 This PR fixes image paste/upload under WSL (see #4683). I've validated locally (build + clippy + fmt + tests). |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…TF-16LE default) and pwsh (UTF-8 default).
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex run build-test and Check for spelling errors |
|
Note To use Codex here, create an environment for this repo. |
|
@codex run build-test and Check for spelling errors |
|
Note To use Codex here, create an environment for this repo. |
|
Ready for review |
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@jif-oai Who review ? |


Related issue: #4683 #3939 #2292
Area:
codex-cli(image handling / clipboard & file uploads)Platforms affected: WSL (Ubuntu on Windows 10/11). No behavior change on native Linux/macOS/Windows.
Summary
This PR makes image pasting and file uploads work when running
codex-cliinside WSL.Before this change, attempts to paste or upload images failed with a 403/permission-like error path, or silently no-op, because our code path assumed a native Linux/Windows environment and mishandled file/byte transfer across the WSL↔Windows boundary.
Root cause
The CLI treated image sources uniformly and:
Under WSL,
wslpathnormalization and host/guest boundary handling were missing, so the upload layer couldn’t resolve a valid, readable path for the file data.Error handling masked the underlying cause, making it look like a generic permission or transport failure.
What this PR changes
WSL detection & path normalization
Detects WSL reliably (checks
/proc/sys/kernel/osreleaseandWSL_INTEROP).Normalizes paths with
wslpath:wslpath -uwslpath -wRobust two-step upload strategy
Deterministic temp location & cleanup
${XDG_CACHE_HOME}/codex/tmpor%LOCALAPPDATA%\codex\tmp).Clearer diagnostics
Small refactors for testability
Tests
Manual validation (WSL2, Windows 11)
C:\Users\...\Picturesinto the terminal → works (WSL fallback copies to temp and uploads)./home/<user>/Downloads/foo.png) → works (no fallback needed).Automated
New unit tests for:
wslpathnormalization (guarded with feature flag/stubbed)Backwards compatibility / risk
Performance
Security / privacy
0600equivalent).Documentation
docs/troubleshooting.mdfor WSL users, I can include that in this PR or a follow-up.How to reproduce the original bug (pre-fix)
codex-cliinside WSL2 on Windows.C:\...into the terminal.How to verify the fix
codex-cliinside WSL2.I’m happy to adjust paths, naming, or split helpers into a separate module if you prefer.