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/ via opencode serve --hostname 0.0.0.0 --port 4096
- Desktop App connects to
http://localhost:4096
- Desktop App sends the project widget value
\\wsl.localhost\Debian as 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
workdir for all tool calls in the session
- Bash calls without explicit
workdir fail 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_spawn produce 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 serve inside 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
workdir parameter
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
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) inopencode.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:
/bin/bashexists. The real failure is thatposix_spawncannotchdirto the non-existent mangled working directory before spawning the process, and reports ENOENT against the executable path instead.How the path gets mangled:
/home/me/OpenCode/viaopencode serve --hostname 0.0.0.0 --port 4096http://localhost:4096\\wsl.localhost\Debianas the session directory/home/me/OpenCode+\\wsl.localhost\Debian=/home/me/OpenCode/\\wsl.localhost\Debianworkdirfor all tool calls in the sessionworkdirfail because the directory doesn't existServer log evidence (
~/.local/share/opencode/log/):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:Additional observations:
~/causes worse mangling:/home/me/\\wsl.localhost\Debian\home\me\...~/OpenCode/directory was created as a workaroundSuggested fixes:
Server-side:
\\wsl.localhost\<distro>\...to/...posix_spawnproduce a misleading ENOENTDesktop App:
\\wsl.localhost\<distro>\...to/...before sendingPlugins
None
OpenCode Server version
1.3.3
OpenCode Desktop version
v1.3.3
Steps to reproduce
opencode serveinside WSL2\\wsl.localhost\Debian(the WSL root)workdirparameterScreenshot and/or share link
N/A — error is in server logs and tool output, not visual.
Operating System
Terminal