Repository navigation
Description
Description
When the OpenCode Desktop App (Windows) connects to an OpenCode server running inside WSL2, the project widget stores Windows UNC paths (\\wsl.localhost\Debian) in opencode.global.dat. The server concatenates this with its own CWD, producing a non-existent path that breaks all bash tool calls with a misleading error.
First — compliments to the team for considering and implementing the Windows + WSL use-case. The ability to run the server in WSL and connect from the Desktop App on Windows is genuinely useful and appreciated.
Error message:
ENOENT: no such file or directory, posix_spawn '/bin/bash'
/bin/bash exists. The real failure is that posix_spawn cannot chdir to the non-existent mangled working directory before spawning the process, and reports ENOENT against the executable path instead.
How the path gets mangled:
- OpenCode server launched from
/home/me/OpenCode/viaopencode serve --hostname 0.0.0.0 --port 4096 - Desktop App connects to
http://localhost:4096 - Desktop App sends the project widget value
\\wsl.localhost\Debianas the session directory - Server resolves it relative to its CWD:
/home/me/OpenCode+\\wsl.localhost\Debian=/home/me/OpenCode/\\wsl.localhost\Debian - This becomes the default
workdirfor all tool calls in the session - Bash calls without explicit
workdirfail because the directory doesn't exist
Server log evidence (~/.local/share/opencode/log/):
service=default directory=/home/me/OpenCode creating instance
service=default directory=/home/me/OpenCode/\\wsl.localhost\Debian\home\me\Projects\... creating instance
service=default directory=/home/me/OpenCode/\\wsl.localhost\Debian creating instance
Desktop App state file (%APPDATA%\ai.opencode.desktop\opencode.global.dat):
{
"projects": {
"local": [{ "worktree": "\\\\wsl.localhost\\Debian", "expanded": true }]
},
"lastProject": { "local": "\\\\wsl.localhost\\Debian" }
}Note: this file uses stringified JSON inside JSON — top-level keys map to string values that are themselves JSON.
Session database (~/.local/share/opencode/opencode.db) persists the mangled paths:
directory=/home/me/OpenCode/\\wsl.localhost\Debian
Additional observations:
- Launching the server from
~/causes worse mangling:/home/me/\\wsl.localhost\Debian\home\me\... - A dedicated
~/OpenCode/directory was created as a workaround
Suggested fixes:
Server-side:
- Detect UNC paths on Linux (never valid on a Linux filesystem) and reject or auto-translate
\\wsl.localhost\<distro>\...to/... - Fall back to server's own CWD if the resolved working directory does not exist
- Log a clear warning instead of letting
posix_spawnproduce a misleading ENOENT
Desktop App:
- Do not send raw Windows UNC paths to a Linux-hosted server
- Translate
\\wsl.localhost\<distro>\...to/...before sending
Plugins
None
OpenCode Server version
1.3.3
OpenCode Desktop version
v1.3.3
Steps to reproduce
- Install OpenCode Desktop on Windows
- Start
opencode serveinside WSL2 - Connect the Desktop App to the WSL server
- Use the project widget to open
\\wsl.localhost\Debian(the WSL root) - Start a session and run any bash command without an explicit
workdirparameter
Screenshot and/or share link
N/A — error is in server logs and tool output, not visual.
Operating System
- Windows 10.0.26200.8037
- WSL2 2.6.1.0 (upgrade to 2.6.3 pending)
- WSL2 kernel 6.6.87.2-microsoft-standard-WSL2
- Debian GNU/Linux 13 (trixie)
- Bash 5.2.37(1)-release
Terminal
- Windows Terminal 1.23.20211.0
- OpenCode Desktop App 1.3.3 (installed from official instructions), connected to WSL-hosted OpenCode server 1.3.3
Activity
github-actions commentedon Mar 28, 2026
This issue might be a duplicate of or related to existing issues. Please check:
am-diff commentedon Mar 29, 2026
Thanks for flagging the potential overlap. I've reviewed #17418 and these are distinct issues with different root causes and severity levels.
#17418 is a UI regression in the project file picker — it shows Windows local paths instead of remote Linux paths when connected to a remote server. The user can't navigate to the right directory. Inconvenient, but the session itself still functions if you work around the picker.
This issue (#19473) is a breakage in the path resolution pipeline. The Desktop App sends a raw Windows UNC path (
\\wsl.localhost\Debian) to the WSL-hosted server, which concatenates it with its own CWD to produce a non-existent path like/home/me/OpenCode/\\wsl.localhost\Debian. This becomes the defaultworkdirfor all tool calls in the session. Every bash invocation fails with a misleadingENOENT. The session is non-functional.Key differences:
The fix areas are also different: #17418 needs the file picker to query the remote filesystem. This issue needs the server to either reject or translate UNC paths on Linux, and the Desktop App to not send them to a Linux-hosted server in the first place.
SsparKluo commentedon Apr 5, 2026
Also met this problem, and currently you can enable mdns and mdns-domain (by --mdns --mdns-domain), and connect the wsl2 server those the mdns-domain (instead of localhost) to bypass the issue.
am-diff commentedon Apr 6, 2026
@SsparKluo this is great, thanks for sharing. Requires
mirrorednetworking in WSL2.[-]Desktop App sends UNC paths to WSL-hosted server, breaking all bash tool calls[/-][+]Desktop App sends UNC paths to WSL-hosted server, breaking all bash tool calls [WORKAROUND ✅ ][/+]Bilge commentedon May 22, 2026
I also have this issue but do not understand the workaround at all. How do you work around it?
snarkipus commentedon Jun 13, 2026
Workaround (v1.17.5)
romanilyin commentedon Jun 27, 2026
This appears to share the same server-boundary failure described in #33107: a Windows/UNC path is treated as relative by the POSIX server.
The first PR (#34256) rejects that path before instance loading with a clear 400. Explicit UNC-to-WSL translation is intentionally out of scope until the client/server path relationship is known.
am-diff commentedon Jul 1, 2026
Clarifying my previous response. Does not require
mirrorednetworking in.wslconfig;mirroredwas required on only one machine, since then I've been usingnaton a few other machines.github-actions commentedon Aug 31, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.