Skip to content

Desktop App sends UNC paths to WSL-hosted server, breaking all bash tool calls [WORKAROUND ✅ ] #19473

Description

@am-diff

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:

  1. OpenCode server launched from /home/me/OpenCode/ via opencode serve --hostname 0.0.0.0 --port 4096
  2. Desktop App connects to http://localhost:4096
  3. Desktop App sends the project widget value \\wsl.localhost\Debian as the session directory
  4. Server resolves it relative to its CWD: /home/me/OpenCode + \\wsl.localhost\Debian = /home/me/OpenCode/\\wsl.localhost\Debian
  5. This becomes the default workdir for all tool calls in the session
  6. 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

  1. Install OpenCode Desktop on Windows
  2. Start opencode serve inside WSL2
  3. Connect the Desktop App to the WSL server
  4. Use the project widget to open \\wsl.localhost\Debian (the WSL root)
  5. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions